#!/bin/bash # Variables KEY_NAME="uam-bwc-key" INSTANCE_TYPE="t2.micro" SECURITY_GROUP_NAME="uam-bwc-sg" AMI_ID="ami-0ddc798b3f1a5117e" REGION="us-east-1" # Generate SSH key pair aws ec2 create-key-pair --key-name $KEY_NAME --query 'KeyMaterial' --output text --region $REGION > ${KEY_NAME}.pem chmod 400 ${KEY_NAME}.pem # Create security group SECURITY_GROUP_ID=$(aws ec2 create-security-group --group-name $SECURITY_GROUP_NAME --description "Security group for uam-bwc EC2 instance" --query 'GroupId' --output text --region $REGION) # Add rules to security group aws ec2 authorize-security-group-ingress --group-id $SECURITY_GROUP_ID --protocol tcp --port 22 --cidr 0.0.0.0/0 --region $REGION aws ec2 authorize-security-group-ingress --group-id $SECURITY_GROUP_ID --protocol tcp --port 80 --cidr 0.0.0.0/0 --region $REGION aws ec2 authorize-security-group-ingress --group-id $SECURITY_GROUP_ID --protocol tcp --port 443 --cidr 0.0.0.0/0 --region $REGION # User data script USER_DATA_SCRIPT=$(cat <