Export Existing EC2 instance to CloudFormation json/yaml

Chris Bolton

Problem:

I have an EC2 instance running and I have made some modifications to the instance: installed docker, setup directories for certs, etc. Now, I am wanting to create the same instance but use infrastructure as code principals. Instead of remembering all the additions that I have done and creating a template by hand, I am trying to find a way to export my current EC2 instance into a json or yaml format so that I can terminate this instance and create another one that is equivalent to the one running.

I have tried:

aws ec2 describe-instances

Reading through the AWS CLI EC2 docs

Reading through the CloudFormation docs

Searched Google

Searched SO

John Rotenstein

Since you have no knowledge of how the instance was setup, the only choice is to create an Amazon Machine Image (AMI). This will create an exact copy of the disk, so everything you have installed will be available to any new instances launched from the AMI. The CloudFormation template can then be configured to launch instances using this AMI.

If, on the other hand, you knew all the commands that needed to be run to configure the instance, then you could provide a User Data script that would run when new instances first boot. This would configure the instances automatically and is the recommended way to configure instances because it is easy to modify and allows instances to launch with the latest version of the Operating System.

Such a script can be provided as part of a CloudFormation template.

See: Running commands on your Linux instance at launch - Amazon EC2

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

I am not able to copy S3 file to EC2 instance using Userdata in CloudFormation

分類Dev

Install NEO4J graph database on existing Amazon EC2 instance

分類Dev

CloudFormation AWS :: EC2 :: Instanceはインスタンスの数を指定します

分類Dev

Recover terminated EC2 Instance

分類Dev

Spontaneous shutdowns in AWS EC2 instance

分類Dev

Point EC2 instance to GoDaddy domain

分類Dev

ssh to Ubuntu instance on Amazon EC2

分類Dev

Change Instance type of a cluster registered ec2 instance

分類Dev

Installing phpMyAdmin onto Amazon EC2 instance

分類Dev

Is it possible to enable CloudWatch on a running EC2 instance?

分類Dev

AWS IAM: Allow EC2 instance to stop itself

分類Dev

Amazon EC2 Ubuntu Instance Maximum File Upload Size

分類Dev

AWS EC2, command line display instance type

分類Dev

Charged if Amazon EC2 instance is on but do nothing?

分類Dev

'Launch More like this' AWS EC2 instance

分類Dev

What is EC2 previous-instance-id?

分類Dev

Need to create Database on Amazon EC2 instance

分類Dev

is history of ec2 instance scheduled events available anywhere?

分類Dev

cannot reach EC2 instance in ECS cluster

分類Dev

How to run tasks with sudo from ansible in EC2 instance

分類Dev

AWS ec2 instance not open from some ip

分類Dev

Redirect URL for Google API client on AWS ec2 instance?

分類Dev

Crontab failing to run on AWS ec2 Ubuntu Instance

分類Dev

Crontab failing to run on AWS ec2 Ubuntu Instance

分類Dev

How to manage third party files in replicable EC2 instance?

分類Dev

SQS: Publish a message when an EC2 instance starts?

分類Dev

Connect to Amazon ec2 Instance without specifying .pem file

分類Dev

How to ssh into EC2 instance without PEM key?

分類Dev

EC2 Error using Cloudformation: Service: AmazonEC2; Status Code: 400; Error Code: IncorrectInstanceState

Related 関連記事

  1. 1

    I am not able to copy S3 file to EC2 instance using Userdata in CloudFormation

  2. 2

    Install NEO4J graph database on existing Amazon EC2 instance

  3. 3

    CloudFormation AWS :: EC2 :: Instanceはインスタンスの数を指定します

  4. 4

    Recover terminated EC2 Instance

  5. 5

    Spontaneous shutdowns in AWS EC2 instance

  6. 6

    Point EC2 instance to GoDaddy domain

  7. 7

    ssh to Ubuntu instance on Amazon EC2

  8. 8

    Change Instance type of a cluster registered ec2 instance

  9. 9

    Installing phpMyAdmin onto Amazon EC2 instance

  10. 10

    Is it possible to enable CloudWatch on a running EC2 instance?

  11. 11

    AWS IAM: Allow EC2 instance to stop itself

  12. 12

    Amazon EC2 Ubuntu Instance Maximum File Upload Size

  13. 13

    AWS EC2, command line display instance type

  14. 14

    Charged if Amazon EC2 instance is on but do nothing?

  15. 15

    'Launch More like this' AWS EC2 instance

  16. 16

    What is EC2 previous-instance-id?

  17. 17

    Need to create Database on Amazon EC2 instance

  18. 18

    is history of ec2 instance scheduled events available anywhere?

  19. 19

    cannot reach EC2 instance in ECS cluster

  20. 20

    How to run tasks with sudo from ansible in EC2 instance

  21. 21

    AWS ec2 instance not open from some ip

  22. 22

    Redirect URL for Google API client on AWS ec2 instance?

  23. 23

    Crontab failing to run on AWS ec2 Ubuntu Instance

  24. 24

    Crontab failing to run on AWS ec2 Ubuntu Instance

  25. 25

    How to manage third party files in replicable EC2 instance?

  26. 26

    SQS: Publish a message when an EC2 instance starts?

  27. 27

    Connect to Amazon ec2 Instance without specifying .pem file

  28. 28

    How to ssh into EC2 instance without PEM key?

  29. 29

    EC2 Error using Cloudformation: Service: AmazonEC2; Status Code: 400; Error Code: IncorrectInstanceState

ホットタグ

アーカイブ