From e27791486b10b941a6ee03261aeb7d2e3e575bd0 Mon Sep 17 00:00:00 2001 From: fidelis-ogunsanmi Date: Fri, 8 Jul 2022 15:10:40 -0400 Subject: [PATCH 1/3] added changes to module 2 --- 02-s3/data/index-2.html | 12 ++++++ 02-s3/data/index.html | 12 ++++++ 02-s3/data/private-file.md | 3 ++ 02-s3/exec.sh | 84 ++++++++++++++++++++++++++++++++++++++ 02-s3/labs | 10 +++++ 02-s3/name.json | 5 +++ 02-s3/s3.yaml | 32 +++++++++++++++ 7 files changed, 158 insertions(+) create mode 100644 02-s3/data/index-2.html create mode 100644 02-s3/data/index.html create mode 100644 02-s3/data/private-file.md create mode 100755 02-s3/exec.sh create mode 100644 02-s3/labs create mode 100644 02-s3/name.json create mode 100644 02-s3/s3.yaml diff --git a/02-s3/data/index-2.html b/02-s3/data/index-2.html new file mode 100644 index 00000000..0a896d31 --- /dev/null +++ b/02-s3/data/index-2.html @@ -0,0 +1,12 @@ + + + + + + + Index2 HTML Page + + + I love TECH. I love stelligent + + \ No newline at end of file diff --git a/02-s3/data/index.html b/02-s3/data/index.html new file mode 100644 index 00000000..fd2711b0 --- /dev/null +++ b/02-s3/data/index.html @@ -0,0 +1,12 @@ + + + + + + + Index1 HTML Page + + + I love TECH. I love stelligent + + \ No newline at end of file diff --git a/02-s3/data/private-file.md b/02-s3/data/private-file.md new file mode 100644 index 00000000..ca38ad6c --- /dev/null +++ b/02-s3/data/private-file.md @@ -0,0 +1,3 @@ +# This is a test private file + +- made first change diff --git a/02-s3/exec.sh b/02-s3/exec.sh new file mode 100755 index 00000000..adbc1346 --- /dev/null +++ b/02-s3/exec.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +PROFILE="labmfa" +BUCKET_NAME="stelligent-u-fidelisogunsanmi" +STACK_NAME="fidelistestlab" +TEMPLATE="s3.yaml" +REGION="us-west-2" +PARAMETERS="file://name.json" + +# Lab 2.1.1: Create a Bucket +# aws s3 mb s3://$BUCKET_NAME \ +# --profile $PROFILE \ +# --region $REGION + +# List contents of the bucket +# aws s3 ls s3://$BUCKET_NAME \ +# --profile $PROFILE + +# Lab 2.1.2: Upload Objects to a Bucket + +# aws s3 cp data/index.html s3://$BUCKET_NAME/index.html \ +# --profile $PROFILE + +# aws s3 sync data s3://$BUCKET_NAME/data \ +# --profile $PROFILE \ +# --exclude "private-file" + +# Nobody else can see the bucket at this point. + +# The sync command is what you want +# as it is designed to handle keeping two folders in sync while copying the minimum amount of data. +# Sync should result in less data being pushed into S3 bucket so that should have a less cost overall. + +# Lab 2.1.3: Exclude Private Objects When Uploading to a Bucket + +# aws s3 cp data s3://$BUCKET_NAME \ +# --recursive --exclude "private-file" \ +# --profile $PROFILE + +# Lab 2.1.4: Clean Up + +# aws s3 rm s3://$BUCKET_NAME/data/private-file \ +# --recursive \ +# --profile $PROFILE + +# aws s3 rb s3://$BUCKET_NAME \ +# --profile $PROFILE \ +# --force + +# Lab 2.2.1: Recreate the Bucket with Public Data + +# aws s3 sync data s3://$BUCKET_NAME/data \ +# --profile $PROFILE \ +# # --acl public-read + +# Lab 2.2.2: Use the CLI to Restrict Access to Private Data +# aws s3 sync data s3://$BUCKET_NAME/data \ +# --profile $PROFILE \ +# --acl private + +# Lab 2.3.1: Set up for Versioning +# aws cloudformation deploy --template-file $TEMPLATE \ +# --stack-name $STACK_NAME --profile $PROFILE \ +# --region $REGION + +# # After syncing the modified local files, we have different versions of the files since versioning is enabled + +# Lab 2.3.2: Object Versions + +# After deleting the object i can still fetch the deleted object cos of versioning + +# To delete versioned objects permanently, you must use DELETE Object versionId. + +# Lab 2.3.3: Tagging S3 Resources + +# Updated the CFN template to add tags to the bucket + +# With Amazon S3 tagging, if you want to add or replace a tag in a tag set (all the tags associated with an object or bucket), +# you must download all the tags, modify the tags, and then replace all the tags at once. + +# Lab 2.3.4: Object Lifecycles + +# The CFN template has all the details to create the lifecycles + diff --git a/02-s3/labs b/02-s3/labs new file mode 100644 index 00000000..1fb2bba0 --- /dev/null +++ b/02-s3/labs @@ -0,0 +1,10 @@ +Lab 2.1.1 +Lab 2.1.2 +Lab 2.1.3 +Lab 2.1.4 +Lab 2.2.1 +Lab 2.2.2 +Lab 2.3.1 +Lab 2.3.2 +Lab 2.3.3 +Lab 2.3.4 \ No newline at end of file diff --git a/02-s3/name.json b/02-s3/name.json new file mode 100644 index 00000000..eefa3191 --- /dev/null +++ b/02-s3/name.json @@ -0,0 +1,5 @@ +{ + "Parameters": { + "BucketName": "stelligent-u-fidelisogunsanmi" + } +} \ No newline at end of file diff --git a/02-s3/s3.yaml b/02-s3/s3.yaml new file mode 100644 index 00000000..324458d6 --- /dev/null +++ b/02-s3/s3.yaml @@ -0,0 +1,32 @@ +AWSTemplateFormatVersion: 2010-09-09 +Description: CloudFormation template for s3 bucket + +Resources: + S3Bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: stelligent-u-fidelisogunsanmi + VersioningConfiguration: + Status: Enabled + LifecycleConfiguration: + Rules: + - Id: S3Rule + Status: Enabled + Transitions: + - TransitionInDays: 30 + StorageClass: STANDARD_IA + - TransitionInDays: 90 + StorageClass: GLACIER + NoncurrentVersionExpiration: + NewerNoncurrentVersions: 5 + NoncurrentDays: 7 + AbortIncompleteMultipartUpload: + DaysAfterInitiation: 1 + + Tags: + - Key: Environment + Value: Lab +Outputs: + BucketName: + Value: !Ref S3Bucket + Description: Name of the sample Amazon S3 bucket with a lifecycle configuration. \ No newline at end of file From 2e44a14a4d3eb2a22413e740a07cd41c76c9c204 Mon Sep 17 00:00:00 2001 From: fidelis-ogunsanmi Date: Fri, 8 Jul 2022 15:15:11 -0400 Subject: [PATCH 2/3] added changes --- 02-s3/exec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/02-s3/exec.sh b/02-s3/exec.sh index adbc1346..b2ffa2ec 100755 --- a/02-s3/exec.sh +++ b/02-s3/exec.sh @@ -73,12 +73,12 @@ PARAMETERS="file://name.json" # Lab 2.3.3: Tagging S3 Resources -# Updated the CFN template to add tags to the bucket +# Updated the CFN template - "s3.yaml" to add tags to the bucket # With Amazon S3 tagging, if you want to add or replace a tag in a tag set (all the tags associated with an object or bucket), # you must download all the tags, modify the tags, and then replace all the tags at once. # Lab 2.3.4: Object Lifecycles -# The CFN template has all the details to create the lifecycles +# The CFN template - "s3.yaml" has all the details to create the lifecycles From c90c43eeee4f8c34ad81df6a9761d0606165216f Mon Sep 17 00:00:00 2001 From: fidelis-ogunsanmi Date: Tue, 26 Jul 2022 12:04:18 -0400 Subject: [PATCH 3/3] added changes --- 02-s3/exec.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/02-s3/exec.sh b/02-s3/exec.sh index b2ffa2ec..8e4697fa 100755 --- a/02-s3/exec.sh +++ b/02-s3/exec.sh @@ -17,7 +17,6 @@ PARAMETERS="file://name.json" # --profile $PROFILE # Lab 2.1.2: Upload Objects to a Bucket - # aws s3 cp data/index.html s3://$BUCKET_NAME/index.html \ # --profile $PROFILE