From 7a9b41a5dfd68e99ce223cb8ee2e29b4aa85833b Mon Sep 17 00:00:00 2001 From: Jan Helak Date: Thu, 31 Oct 2024 11:44:14 +0100 Subject: [PATCH] corrections --- skrypty/create-ec2-for-inspector.sh | 41 +++++++++++++++++++++++++++++ zadania.md | 11 ++++---- 2 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 skrypty/create-ec2-for-inspector.sh diff --git a/skrypty/create-ec2-for-inspector.sh b/skrypty/create-ec2-for-inspector.sh new file mode 100644 index 0000000..f04f85d --- /dev/null +++ b/skrypty/create-ec2-for-inspector.sh @@ -0,0 +1,41 @@ +#!/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 <