Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a VPC error when trying to run the CloudFormation step in Chapter 2 #8

Open
indrayam opened this issue Sep 2, 2020 · 5 comments

Comments

@indrayam
Copy link

indrayam commented Sep 2, 2020

Book version: 1.3, 2020-02-03

I am getting this error in Chapter 2 when I run the ./deploy-infra.sh step...

The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request. (Service: AmazonEC2; Status Code: 400; Error Code: VPCResourceNotSpecified; Request ID: 5bdea2d7-db4a-42ef-9932-8311faef9cc0; Proxy: null)

Anand

@dvassallo
Copy link
Collaborator

Hey Anand — Could it be that you're using an AWS account created before 2013? There's a legacy feature in old accounts where you can run EC2 instances without a VPC, and therefore the AWS account doesn't come with a default VPC automatically configured.

Here's how you can check: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-classic-platform.html

@indrayam
Copy link
Author

indrayam commented Sep 2, 2020

Thanks @dvassallo

I am pretty sure mine was created before 2013. Or at least, I would not be surprised. Plus, this output seems to suggest that my account does support both EC2-Classic and Amazon VPC..

image

image

I do have a non-default VPC already created in the region where I am playing with aws-bootstrap. What I do not know is how to pass the VPC ID in CloudFormation template. Any tips?

@dvassallo
Copy link
Collaborator

Yes, you're on a legacy account.

From page 93 onwards, it will work in your account because you'd be creating a VPC explicitly rather than relying on the default one.

Screen Shot 2020-09-02 at 11 06 23

If you're already reasonably familiar with AWS, you may want to just read through those early chapters and then get back to the guide from the Load Balancing chapter onwards. Note that the code is tagged by chapter in this repo, so you can pick from any point: https://github.com/good-parts/aws-bootstrap/tags

Alternatively, you can create a brand new AWS account just for the tutorial. It's free and takes only a couple of minutes. The final template will work fine even in your original account, but because of this quirk the initial chapters might be easier to follow using a new AWS account.

@indrayam
Copy link
Author

indrayam commented Sep 2, 2020

@dvassallo You're awesome!

Btw, for now, I just brute-forced my way by adding the following to Chapter 2's main.yml:

  • Manually added my VpcId to SecurityGroup Resource definition
  • Manually added SubnetId to my Instance Resource definition

While I was at it, I also added KeyName property to the new Instance so that I could SSH into it as well.

Ah, one more thing. The Vpc did not have DNS Hostnames attribute enabled by default. So had to set that one up manually as well. I did peek into the CloudFormation template in the master branch and noticed that we will be creating a new Vpc with that field enabled.

Anyways, I am going to keep going. I am assuming that as long as I do not delete that Vpc and the Subnet, I should be all set!

@dvassallo
Copy link
Collaborator

Wonderful. Note that you don't need Key Pairs anymore to SSH to EC2 instances since the release of EC2 Connect: https://aws.amazon.com/about-aws/whats-new/2019/06/introducing-amazon-ec2-instance-connect/ — It's a bit more convenient especially when automating infrastructure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants