From dbceeeef82569b784821f3f741328ac973242a5e Mon Sep 17 00:00:00 2001
From: fidelis-ogunsanmi
Date: Thu, 28 Jul 2022 12:12:04 -0400
Subject: [PATCH] added changes
---
11-parameter-store/11-1-1.yaml | 102 ++++++++++++++++++
11-parameter-store/11-1-3.yaml | 182 +++++++++++++++++++++++++++++++++
11-parameter-store/11-1-4.yaml | 161 +++++++++++++++++++++++++++++
11-parameter-store/exec.sh | 13 +++
11-parameter-store/params.json | 10 ++
5 files changed, 468 insertions(+)
create mode 100644 11-parameter-store/11-1-1.yaml
create mode 100644 11-parameter-store/11-1-3.yaml
create mode 100644 11-parameter-store/11-1-4.yaml
create mode 100755 11-parameter-store/exec.sh
create mode 100644 11-parameter-store/params.json
diff --git a/11-parameter-store/11-1-1.yaml b/11-parameter-store/11-1-1.yaml
new file mode 100644
index 00000000..78fe0a81
--- /dev/null
+++ b/11-parameter-store/11-1-1.yaml
@@ -0,0 +1,102 @@
+AWSTemplateFormatVersion: '2010-09-09'
+Description: 'Lab 11.1.1'
+
+Parameters:
+ Name:
+ Type: String
+
+ UserName:
+ Type: String
+
+ Title:
+ Type: String
+
+ StreetAddress:
+ Type: String
+
+ City:
+ Type: String
+
+ State:
+ Type: String
+ Default: MD
+ MaxLength: "2"
+ MinLength: "2"
+ AllowedPattern: "^[A-Z]{2}$"
+
+ TimeZone:
+ Type: String
+ Default: EST
+ MaxLength: "3"
+ MinLength: "3"
+
+ StartDate:
+ Type: String
+ Default: "2022-06-20"
+
+ Team:
+ Type: String
+
+Resources:
+ ineerUserName:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/UserName
+ Type: String
+ Value: !Ref UserName
+
+ ineerName:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/Name
+ Type: String
+ Value: !Ref Name
+
+ ineerAddress:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/Address
+ Type: String
+ Value: !Ref StreetAddress
+
+ ineerTitle:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/Title
+ Type: String
+ Value: !Ref Title
+
+ ineerState:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/State
+ Type: String
+ Value: !Ref State
+
+ ineerCity:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/City
+ Type: String
+ Value: !Ref City
+
+ ineerTimeZone:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/TimeZone
+ Type: String
+ Value: !Ref TimeZone
+
+ ineerTeam:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/Team
+ Type: String
+ Value: !Ref Team
+
+ ineerStartDate:
+ Type: AWS::SSM::Parameter
+ Properties:
+ Name: !Sub /${UserName}/StartDate
+ Type: String
+ Value: !Ref StartDate
\ No newline at end of file
diff --git a/11-parameter-store/11-1-3.yaml b/11-parameter-store/11-1-3.yaml
new file mode 100644
index 00000000..53d87f83
--- /dev/null
+++ b/11-parameter-store/11-1-3.yaml
@@ -0,0 +1,182 @@
+AWSTemplateFormatVersion: '2010-09-09'
+Parameters:
+ TopLevelParameter:
+ Type: AWS::SSM::Parameter::Name
+ Default: /fidelis.ogunsanmi.labs/UserName
+ Description: "User Name for the engineer"
+
+ UserName:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/UserName
+
+ Name:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Name
+
+ StreetAddress:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Address
+
+ City:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/City
+
+ Team:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Team
+
+ StartDate:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/StartDate
+
+ Timezone:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/TimeZone
+
+ Title:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Title
+
+ State:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/State
+
+Resources:
+ ALBSG:
+ Type: "AWS::EC2::SecurityGroup"
+ Properties:
+ GroupDescription: "security group for ALB"
+ GroupName: "test-ALB-SG"
+ VpcId: !ImportValue fidelisVpc
+ SecurityGroupIngress:
+ -
+ CidrIp: "0.0.0.0/0"
+ FromPort: 80
+ IpProtocol: "tcp"
+ ToPort: 80
+ -
+ CidrIp: "0.0.0.0/0"
+ FromPort: 443
+ IpProtocol: "tcp"
+ ToPort: 443
+
+ ALB:
+ Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
+ Properties:
+ Name: "test-Application-Load-Balancer"
+ Scheme: "internet-facing"
+ Type: "application"
+ Subnets:
+ - !ImportValue fidelisPubSubnet
+ - !ImportValue fidelisPubSubnet2
+ SecurityGroups:
+ - !Ref ALBSG
+ IpAddressType: "ipv4"
+
+ TargetGroup:
+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
+ Properties:
+ HealthCheckEnabled: true
+ HealthCheckPath: "/BADindex.html"
+ HealthCheckPort: "traffic-port"
+ HealthCheckProtocol: HTTP
+ HealthyThresholdCount: 2
+ UnhealthyThresholdCount: 2
+ HealthCheckIntervalSeconds: 30
+ HealthCheckTimeoutSeconds: 5
+ VpcId: !ImportValue fidelisVpc
+ Protocol: HTTP
+ Port: 80
+ Matcher:
+ HttpCode: "200"
+ TargetGroupAttributes:
+ - Key: deregistration_delay.timeout_seconds
+ Value: "20"
+
+ MyAlbListener:
+ Type: AWS::ElasticLoadBalancingV2::Listener
+ Properties:
+ LoadBalancerArn: !Ref ALB
+ Port: 80
+ Protocol: "HTTP"
+ DefaultActions:
+ - Order: 1
+ TargetGroupArn: !Ref TargetGroup
+ Type: "forward"
+
+ WebServerAsg:
+ Type: 'AWS::AutoScaling::AutoScalingGroup'
+ Properties:
+ AutoScalingGroupName: 'AutomationBoxes'
+ VPCZoneIdentifier:
+ - !ImportValue fidelisPubSubnet
+ - !ImportValue fidelisPubSubnet2
+ DesiredCapacity: '3'
+ HealthCheckType: 'ELB'
+ HealthCheckGracePeriod: 30
+ LaunchConfigurationName: !Ref WebServersLC
+ MaxSize: '3'
+ MinSize: '3'
+ TargetGroupARNs:
+ - !Ref TargetGroup
+
+ WebServersLC:
+ Type: 'AWS::AutoScaling::LaunchConfiguration'
+ Properties:
+ ImageId: 'ami-0cff7528ff583bf9a'
+ InstanceType: 't2.micro'
+ LaunchConfigurationName: 'SimpleWebServerLC'
+ SecurityGroups:
+ - !ImportValue InstancegroupID
+ UserData:
+ Fn::Base64:
+ Fn::Sub: |
+ #!/bin/bash -xe
+
+ yum install -y aws-cfn-bootstrap
+
+ # Install the files and packages from the metadata
+ /opt/aws/bin/cfn-init -v \
+ --stack ${AWS::StackName} \
+ --resource WebServersLC \
+ --configsets All \
+ --region ${AWS::Region}
+
+ # Signal the status from cfn-init
+ /opt/aws/bin/cfn-signal -e $? \
+ --stack ${AWS::StackName} \
+ --resource WebServersLC \
+ --region ${AWS::Region}
+
+ Metadata:
+ 'AWS::CloudFormation::Init':
+ configSets:
+ All:
+ - ConfigureStelligentProject
+ ConfigureStelligentProject:
+ packages:
+ yum:
+ nginx: []
+ files:
+ /usr/share/nginx/html/index.html:
+ content: !Sub |
+ Automation for ${TopLevelParameter}
+ UserName: ${UserName}
+ Full Name: ${Name}
+ Title: ${Title}
+ Address: ${StreetAddress}, ${City}, ${State}
+ Time Zone: ${Timezone}
+ Team Name: ${Team}
+ Start Date ${StartDate}
+ mode: '000644'
+ owner: root
+ group: root
+ services:
+ sysvinit:
+ nginx:
+ enabled: 'true'
+ ensureRunning: 'true'
+
+
+
+
diff --git a/11-parameter-store/11-1-4.yaml b/11-parameter-store/11-1-4.yaml
new file mode 100644
index 00000000..8feca1af
--- /dev/null
+++ b/11-parameter-store/11-1-4.yaml
@@ -0,0 +1,161 @@
+AWSTemplateFormatVersion: '2010-09-09'
+Parameters:
+ TopLevelParameter:
+ Type: AWS::SSM::Parameter::Name
+ Default: /fidelis.ogunsanmi.labs/UserName
+ Description: "User Name for the engineer"
+
+ UserName:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/UserName
+
+ Name:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Name
+
+ StreetAddress:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Address
+
+ City:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/City
+
+ Team:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Team
+
+ StartDate:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/StartDate
+
+ Timezone:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/TimeZone
+
+ Title:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/Title
+
+ State:
+ Type: AWS::SSM::Parameter::Value
+ Default: /fidelis.ogunsanmi.labs/State
+
+Resources:
+ ALBSG:
+ Type: "AWS::EC2::SecurityGroup"
+ Properties:
+ GroupDescription: "security group for ALB"
+ GroupName: "test-ALB-SG"
+ VpcId: !ImportValue fidelisVpc
+ SecurityGroupIngress:
+ -
+ CidrIp: "0.0.0.0/0"
+ FromPort: 80
+ IpProtocol: "tcp"
+ ToPort: 80
+ -
+ CidrIp: "0.0.0.0/0"
+ FromPort: 443
+ IpProtocol: "tcp"
+ ToPort: 443
+
+ ALB:
+ Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
+ Properties:
+ Name: "test-Application-Load-Balancer"
+ Scheme: "internet-facing"
+ Type: "application"
+ Subnets:
+ - !ImportValue fidelisPubSubnet
+ - !ImportValue fidelisPubSubnet2
+ SecurityGroups:
+ - !Ref ALBSG
+ IpAddressType: "ipv4"
+
+ TargetGroup:
+ Type: AWS::ElasticLoadBalancingV2::TargetGroup
+ Properties:
+ HealthCheckEnabled: true
+ HealthCheckPath: "/BADindex.html"
+ HealthCheckPort: "traffic-port"
+ HealthCheckProtocol: HTTP
+ HealthyThresholdCount: 2
+ UnhealthyThresholdCount: 2
+ HealthCheckIntervalSeconds: 30
+ HealthCheckTimeoutSeconds: 5
+ VpcId: !ImportValue fidelisVpc
+ Protocol: HTTP
+ Port: 80
+ Matcher:
+ HttpCode: "200"
+ TargetGroupAttributes:
+ - Key: deregistration_delay.timeout_seconds
+ Value: "20"
+
+ MyAlbListener:
+ Type: AWS::ElasticLoadBalancingV2::Listener
+ Properties:
+ LoadBalancerArn: !Ref ALB
+ Port: 80
+ Protocol: "HTTP"
+ DefaultActions:
+ - Order: 1
+ TargetGroupArn: !Ref TargetGroup
+ Type: "forward"
+
+ WebServerAsg:
+ Type: 'AWS::AutoScaling::AutoScalingGroup'
+ Properties:
+ AutoScalingGroupName: 'AutomationBoxes'
+ VPCZoneIdentifier:
+ - !ImportValue fidelisPubSubnet
+ - !ImportValue fidelisPubSubnet2
+ DesiredCapacity: '3'
+ HealthCheckType: 'ELB'
+ HealthCheckGracePeriod: 30
+ LaunchConfigurationName: !Ref WebServersLC
+ MaxSize: '3'
+ MinSize: '3'
+ TargetGroupARNs:
+ - !Ref TargetGroup
+
+ WebServersLC:
+ Type: 'AWS::AutoScaling::LaunchConfiguration'
+ Properties:
+ ImageId: 'ami-0cff7528ff583bf9a'
+ InstanceType: 't2.micro'
+ LaunchConfigurationName: 'SimpleWebServerLC'
+ SecurityGroups:
+ - !ImportValue InstancegroupID
+ UserData:
+ Fn::Base64:
+ Fn::Base64:
+ Fn::Sub: |
+ #!/bin/bash -xe
+ amazon-linux-extras install -y aws-cfn-bootstrap
+ amazon-linux-extras install -y nginx1
+ service nginx start
+ middlename = $(aws ssm get-parameter --name /fidelis.ogunsanmi.labs/middlename --with-decryption --query Parameter.Value --output text --region us-west-1)
+ echo <<< EOL
+ Automation for ${ParameterName}
+ UserName: ${UserName}
+ Full Name: ${Name}
+ MiddleName: $(aws ssm get-parameter --name /fidelis.ogunsanmi.labs/middlename --with-decryption --query Parameter.Value --output text --region us-west-1)
+ UserName: ${UserName}
+ Title: ${Title}
+ Address: ${StreetAddress}, ${City}, ${State}
+ Time Zone: ${TimeZone}
+ Team Name: ${TeamName}
+ Start Date ${StartDate}
+ EOL >> /usr/share/nginx/html/index.html;
+
+ # Signal the status from cfn-init
+ /opt/aws/bin/cfn-signal -e $? \
+ --stack ${AWS::StackName} \
+ --resource WebServersLC \
+ --region ${AWS::Region}
+
+
+
+
diff --git a/11-parameter-store/exec.sh b/11-parameter-store/exec.sh
new file mode 100755
index 00000000..9b38cbb5
--- /dev/null
+++ b/11-parameter-store/exec.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+STACK_NAME="fideliSssm"
+TEMPLATE="11-1-3.yaml"
+PROFILE="labmfa"
+PARAMETER="file://params.json"
+REGION="us-east-1"
+
+
+aws cloudformation deploy --template-file $TEMPLATE \
+ --stack-name $STACK_NAME --profile $PROFILE \
+ --parameter-overrides $PARAMETER \
+ --region $REGION
\ No newline at end of file
diff --git a/11-parameter-store/params.json b/11-parameter-store/params.json
new file mode 100644
index 00000000..093ee841
--- /dev/null
+++ b/11-parameter-store/params.json
@@ -0,0 +1,10 @@
+{
+ "Parameters": {
+ "UserName": "fidelis.ogunsanmi.labs",
+ "Name": "Fidelis Ogunsanmi",
+ "Title": "DevOps Guy",
+ "StreetAddress": "19 Olubunmi Alonge str",
+ "City": "Surulere",
+ "Team": "Consultation"
+ }
+}
\ No newline at end of file