ASG-Cloud9-Workshop
Create a new EC2 instance for environment (direct access): EC2 Instance được khởi tạo cùng với Cloud9 environment. Instance được truy cập qua Cloud9 IDE sử dụng phương thức SSH.
Create a new no-ingress EC2 instance for environment (access via Systems Manager): EC2 Instance cũng được khởi tạo cùng với Cloud9 environment và Instance có thể được truy cập qua System Manager.
Create and run in remote server (SSH connection): EC2 Instance đã có sẵn, Cloud9 eviroment thiết lập môi trường để đủ điều kiện truy cập EC2 Instance.
Trong phạm vi bài giới thiệu về dịch vụ CloudFormation hôm nay, để đơn giản và tập trung vào nội dung chính chúng ta sẽ chọn option thứ nhất - EC2 và Cloud9 được khởi tạo cùng lúc và có thể truy cập Instance qua SSH.
Các nội dung cấu hình còn lại ta để mặc định với:
Cost-saving setting: sau 30’ nếu EC2 Instance không có tiến trình nào được chạy, Cloud9 sẽ stop Instance.
IAM Role: AWSServiceRoleForAWSCloud9 - là service-linked role được tạo sẵn bởi AwS và gắn với dịch vụ Cloud9
Environment type, chọn Create a new EC2 instance for environment (direct access)
Instance type, chọn t3.small(2GiB RAM + 2vCPU)
Platform, chọn Amazon Linux 2 (recommended)
sudo yum -y install jq gettext bash-completion moreutils
pip install cfn-lint
cfn-lint --version
pip install taskcat
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')
export AZS=($(aws ec2 describe-availability-zones --query 'AvailabilityZones[].ZoneName' --output text --region $AWS_REGION))
echo "export ACCOUNT_ID=$ACCOUNT_ID" | tee -a ~/.bash_profile
echo "export AWS_REGION=$AWS_REGION" | tee -a ~/.bash_profile
echo "export AZS=${AZS[@]}" | tee -a ~/.bash_profile
aws configure set default.region $AWS_REGION
aws configure get default.region
aws sts get-caller-identity --query Arn | grep CloudFormation-Role -q && echo "IAM role valid" || echo "IAM role NOT valid"