From 5501292cfb5ddb66237790e1ad47fafa6d39f119 Mon Sep 17 00:00:00 2001 From: arielkru <63583491+arielkru@users.noreply.github.com> Date: Tue, 30 Nov 2021 09:40:22 +0200 Subject: [PATCH 1/2] Create pass.yaml --- pass.yaml | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 pass.yaml diff --git a/pass.yaml b/pass.yaml new file mode 100644 index 00000000..a47e052b --- /dev/null +++ b/pass.yaml @@ -0,0 +1,83 @@ +AWSTemplateFormatVersion: '2010-09-09' +Description: AWS CloudFormation Template to deploy insecure infrastructure + +Parameters: + CompanyName: + Description: Company Name + + Type: String + Default: acme + Environment: + Description: Environment + Type: String + + Default: dev + DBName: + Description: Name of the Database + Type: String + + Default: db1 + Password: + Description: Database Password + Type: String + NoEcho: True + + MinLength: 1 + MaxLength: 41 + + AllowedPattern: ^[a-zA-Z0-9]*$ + LatestAmiId: + Type: AWS::SSM::Parameter::Value + Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 + + +Resources: + #################### + ### EC2 in VPC ### + #################### + EC2Instance: + Type: AWS::EC2::Instance + Properties: + AvailabilityZone: + + Fn::Select: + - 0 + - Fn::GetAZs: "" + + InstanceType: t2.nano + SecurityGroupIds: + + - !Ref WebNodeSG + ImageId: !Ref LatestAmiId + SubnetId: !Ref WebSubnet + + Tags: + - Key: Name + Value: !Sub "${AWS::AccountId}-${CompanyName}-${Environment}-ec2" + UserData: + Fn::Base64: | + #!/bin/bash + sudo yum -y update + sudo yum -y install httpd php php-mysqlnd + sudo systemctl enable httpd + sudo systemctl start httpd + export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMAAA + export AWS_SECRET_ACCESS_KEY=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 + export AWS_DEFAULT_REGION=us-west-2 + echo "

Deployed via CloudFormation

" | sudo tee /var/www/html/index.html + + WebHostStorage: + # Unencrypted Volume + + Type: AWS::EC2::Volume + Properties: + AvailabilityZone: !Select + - 0 + + - Fn::GetAZs: "" + #Encrypted: False + Size: 1 + + Tags: + - Key: Name + Value: !Sub "${AWS::AccountId}-${CompanyName}-${Environment}-ebs" From f0a12555724305b5be0043831be98d083e97ee8e Mon Sep 17 00:00:00 2001 From: arielkru <63583491+arielkru@users.noreply.github.com> Date: Tue, 30 Nov 2021 09:40:50 +0200 Subject: [PATCH 2/2] Create fail.yaml --- test/fail.yaml | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test/fail.yaml diff --git a/test/fail.yaml b/test/fail.yaml new file mode 100644 index 00000000..a47e052b --- /dev/null +++ b/test/fail.yaml @@ -0,0 +1,83 @@ +AWSTemplateFormatVersion: '2010-09-09' +Description: AWS CloudFormation Template to deploy insecure infrastructure + +Parameters: + CompanyName: + Description: Company Name + + Type: String + Default: acme + Environment: + Description: Environment + Type: String + + Default: dev + DBName: + Description: Name of the Database + Type: String + + Default: db1 + Password: + Description: Database Password + Type: String + NoEcho: True + + MinLength: 1 + MaxLength: 41 + + AllowedPattern: ^[a-zA-Z0-9]*$ + LatestAmiId: + Type: AWS::SSM::Parameter::Value + Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2 + + +Resources: + #################### + ### EC2 in VPC ### + #################### + EC2Instance: + Type: AWS::EC2::Instance + Properties: + AvailabilityZone: + + Fn::Select: + - 0 + - Fn::GetAZs: "" + + InstanceType: t2.nano + SecurityGroupIds: + + - !Ref WebNodeSG + ImageId: !Ref LatestAmiId + SubnetId: !Ref WebSubnet + + Tags: + - Key: Name + Value: !Sub "${AWS::AccountId}-${CompanyName}-${Environment}-ec2" + UserData: + Fn::Base64: | + #!/bin/bash + sudo yum -y update + sudo yum -y install httpd php php-mysqlnd + sudo systemctl enable httpd + sudo systemctl start httpd + export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMAAA + export AWS_SECRET_ACCESS_KEY=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 + export AWS_DEFAULT_REGION=us-west-2 + echo "

Deployed via CloudFormation

" | sudo tee /var/www/html/index.html + + WebHostStorage: + # Unencrypted Volume + + Type: AWS::EC2::Volume + Properties: + AvailabilityZone: !Select + - 0 + + - Fn::GetAZs: "" + #Encrypted: False + Size: 1 + + Tags: + - Key: Name + Value: !Sub "${AWS::AccountId}-${CompanyName}-${Environment}-ebs"