Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added changes to module 2 #44

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions 02-s3/data/index-2.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index2 HTML Page</title>
</head>
<body>
I love TECH. I love stelligent
</body>
</html>
12 changes: 12 additions & 0 deletions 02-s3/data/index.html
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index1 HTML Page</title>
</head>
<body>
I love TECH. I love stelligent
</body>
</html>
3 changes: 3 additions & 0 deletions 02-s3/data/private-file.md
@@ -0,0 +1,3 @@
# This is a test private file

- made first change
83 changes: 83 additions & 0 deletions 02-s3/exec.sh
@@ -0,0 +1,83 @@
#!/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 - "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 - "s3.yaml" has all the details to create the lifecycles

10 changes: 10 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions 02-s3/name.json
@@ -0,0 +1,5 @@
{
"Parameters": {
"BucketName": "stelligent-u-fidelisogunsanmi"
}
}
32 changes: 32 additions & 0 deletions 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.