Hi All,
I am getting following error when creating my first EC2 instance
SecurityGroup Code:
sg = ec2.SecurityGroup(self.SG_Name)
sg.GroupDescription = self.SG_Description
sg.VpcId = 'vpc-c55a12ab'#Ref('DefaultVPC')
sg_array = []
for sg_name in self.SG_Defination:
sg_array.append(ec2.SecurityGroupRule(IpProtocol=self.SG_Defination[sg_name]['protocol'],
FromPort=self.SG_Defination[sg_name]['FromPort'],
ToPort=self.SG_Defination[sg_name]['ToPort'],
CidrIp=self.SG_Defination[sg_name]['CidrIp']))
sg.SecurityGroupIngress = sg_array
Error: The parameter groupName cannot be used with the parameter subnet
instance = ec2.Instance(instance_name)
instance.ImageId = instance_ami_name
instance.InstanceType = instance_type
instance.SecurityGroups = ['sg-b7e777em']#[Ref(instance_sg)]
instance.KeyName = Ref('InstanceKeyName')
instance.IamInstanceProfile = IAMProfile
instance.SubnetId = 'subnet-12345a12'
self.template.add_resource(instance)
return self.template
when I remove the Subnet I get the following Error:
Error: No default VPC for this user
instance = ec2.Instance(instance_name)
instance.ImageId = instance_ami_name
instance.InstanceType = instance_type
instance.SecurityGroups = ['sg-b3e12345']#[Ref(instance_sg)]
instance.KeyName = Ref('InstanceKeyName')
instance.IamInstanceProfile = IAMProfile
#instance.SubnetId = 'subnet-556a123'
self.template.add_resource(instance)
return self.template