EC2 Error using Cloudformation: Service: AmazonEC2

2019-08-23 08:18发布

问题:

I am trying to set up an EC2 instance that I can use for R since my computer sucks.

I am using this cloudfront template which I found on this help article.

It is so close to working, but not quite there. I tried to launch the instance and received this msg:

The pending-interface-placement instance to which 'eni-001a6e8290f522251' is attached is not in a valid state for this operation (Service: AmazonEC2; Status Code: 400; Error Code: IncorrectInstanceState; Request ID: c372ab81-053d-4225-b6f4-b3edd2421296)

The default ami_id didn't work on the first go, so I replaced it with ami-0cd3dfa4e37921605.

After the error, the rest of the operation rolled back. The AWS account is a new account without any other settings. I created a VPC and an associated subnet and internet gateway for security, plus a key pair for EC2 and an S3 bucket.

回答1:

You need to make a change in the cloudformation template.

Find this section

  RStatsEC2Instance:
Type: AWS::EC2::Instance
DependsOn: RStatsEIP
Properties:
  ImageId: !Ref ImageId
  InstanceType: !Ref InstanceType

Here you need to replace RStatsEIP with RStatsEIPAssociation

This will ensure that the EC2 instance will be created after the elastic IP will be associated with the network interface.

Upload the yaml file and continue.