most-address-4174
11/16/2020, 6:15 PMconst server = new aws.ec2.Instance('xyz-staging-server-instance', {
instanceType: 't2.micro',
vpcSecurityGroupIds: [securityGroup.id], // reference the security group resource above
ami: ami.id,
})
And I get the following error:
aws:ec2:Instance (xyz-staging-server-instance):
error: 1 error occurred:
* Error launching source instance: VPCIdNotSpecified: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.I found this issue, which says specifying a subnet ID should help, but I can’t seem to work out how specifying the
subnetId
property should work 🤔
Has anyone seen/dealt with this before?gentle-diamond-70147
11/16/2020, 6:21 PMsubnetID
is straightforward. If you have an existing Subnet you want to use can just set it as subnetid: 'subnet-abc123'
. Otherwise you can create a VPC, Subnet, etc. and then pass the subnetId
value in the same way.most-address-4174
11/16/2020, 6:28 PMconst stagingVpc = new awsx.ec2.Vpc(
'xyz-staging',
{
numberOfNatGateways: 2,
numberOfAvailabilityZones: 2,
subnets: [
{ type: 'public', name: '1' },
{ type: 'public', name: '2' },
{ type: 'private', name: '1' },
{ type: 'private', name: '2' },
],
},
{}
)
And have a variable: const stagingVpcPublicSubnetIds = stagingVpc.publicSubnetIds
I may be a bit rusty here, but I’m having difficulty taking one of those IDs into my EC2 instance, if I try:
Do you know if there’s an easy way to grab the ID of one of those subnets as a string?gentle-diamond-70147
11/16/2020, 7:22 PMsubnetId: pulumi.output(stagingVpc.publicSubnetIds).apply(it => it[0]),
most-address-4174
11/17/2020, 1:43 PM