Skip to content

arnlec/aws-cdk-ec2-demo

Repository files navigation

EC2 deployment demo

Usage of cdk toolkit to deploy EC2 instances

Getting started

Prerequisites

Use the aws configure command to set up AWS CLI installation with the mandatory informations: Acces Key ID, Secret access key, AWS Region, and output format

Bootstrap AWS CDK is required before the first stack deployment in an AWS environment (Account/Region).

cdk bootstrap

Useful commands

  • cdk deploy deploy this stack to your default AWS account/region
  • cdk destroy destroy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

Access to EC2 instance

Connect to instance using SSH require to use a private key. The private key is store in AWS Secret Manager. Use the below command to get the private key value:

aws secretsmanager get-secret-value --secret-id ec2-ssh-key/Ec2DemoStackKey/private --query SecretString --output text

Ansible

Private key must be save in private_key.pem file.

To check that ec2 instances are available use the below commands:

chmod 600 private_key.pem
cd ansible
ansible -i hosts -m ping all

About

cdk toolkit for EC2 deployment demo

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published