From 53c5a9b3afa44a79fd3d148711d8671364e8c639 Mon Sep 17 00:00:00 2001 From: Biswanath Mukherjee Date: Sat, 3 Feb 2024 11:45:43 +0530 Subject: [PATCH 1/4] Initial checkin --- ec2-s3-express-one-zone-sam/.gitignore | 8 + ec2-s3-express-one-zone-sam/README.md | 93 +++++++++ .../example-pattern.json | 58 ++++++ .../images/architecture.png | Bin 0 -> 13299 bytes ec2-s3-express-one-zone-sam/template.yaml | 194 ++++++++++++++++++ 5 files changed, 353 insertions(+) create mode 100644 ec2-s3-express-one-zone-sam/.gitignore create mode 100644 ec2-s3-express-one-zone-sam/README.md create mode 100644 ec2-s3-express-one-zone-sam/example-pattern.json create mode 100644 ec2-s3-express-one-zone-sam/images/architecture.png create mode 100644 ec2-s3-express-one-zone-sam/template.yaml diff --git a/ec2-s3-express-one-zone-sam/.gitignore b/ec2-s3-express-one-zone-sam/.gitignore new file mode 100644 index 000000000..dbb0539c9 --- /dev/null +++ b/ec2-s3-express-one-zone-sam/.gitignore @@ -0,0 +1,8 @@ +# SAM default build folder +.aws-sam/ + +# macOS +*.DS_Store + +#VS Code +.vscode/ diff --git a/ec2-s3-express-one-zone-sam/README.md b/ec2-s3-express-one-zone-sam/README.md new file mode 100644 index 000000000..9880bfb06 --- /dev/null +++ b/ec2-s3-express-one-zone-sam/README.md @@ -0,0 +1,93 @@ +# Amazon EC2 to Amazon S3 Express One Zone directory bucket + +This sample project creates an Amazon EC2 Instance and Amazon S3 Express One Zone Direct Bucket under the same availability zone. + +Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/ec2-s3-express-one-zone-sam + +Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example. + +## Requirements + +- [Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources. +- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured +- [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +- [AWS Serverless Application Model](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) (AWS SAM) installed + +## Prerequisite +1. Please refer to the [list of availability zones where Amazon S3 Express One Zone is currently supported](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-Endpoints.html) and choose one. +2. Execute the below from command line and make a note of the `ZoneName` and `ZoneId`. It will be required during deployment: + ```bash + aws ec2 describe-availability-zones --region {region-name} + ``` +3. Choose an AMI Id for your region. + +## Deployment Instructions + +1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository: + ```bash + git clone https://github.com/aws-samples/serverless-patterns + ``` +2. Change directory to the pattern directory: + ```bash + cd ec2-s3-express-one-zone-sam + ``` +3. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file: + ```bash + sam deploy --guided + ``` +4. During the prompts: + + - Enter a stack name + - Enter the desired AWS Region. Please refer to the prerequisite 1 and choose a region. + - Enter `AvailabilityZoneName` and `AvailabilityZoneId` as per the prerequisite 2. + - Enter the `ImageId` as per prerequisite 3. + - Allow SAM CLI to create IAM roles with the required permissions. + + Once you have run `sam deploy --guided` mode once and saved arguments to a configuration file (samconfig.toml), you can use `sam deploy` in future to use these defaults. + +5. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for next step as well as testing. + + +## How it works + + +Please refer to the architecture diagram below: + +![End to End Architecture](images/architecture.png) + +S3 Express One Zone is the first S3 storage class that gives you the option to co-locate high-performance object storage and AWS compute resources, such as Amazon Elastic Compute Cloud, Amazon Elastic Kubernetes Service, and Amazon Elastic Container Service, within a single Availability Zone. +Here, we provisioned both the Amazon EC2 instance and the S3 Express One Zone Directory bucket within same availability zone. We will perform both read and write opertation from the directory bucket from within the EC2 instance and outside. + +## Testing + + +1. Log into the Amazon EC2 instance using AWS console and execute the following command to upload file into Amazon S3 Express One Zone diretory bucket. Please replace `BucketExpressOneZoneName` from the `sam deploy -g` output. + ```bash + echo "Hello World!" > sample.txt + aws s3api put-object --bucket {BucketExpressOneZoneName} --key sample.txt --body sample.txt + + ``` +2. Now, download the same file from your laptop command line using the following command and validate the content.: + ```bash + aws s3api get-object --bucket {BucketExpressOneZoneName} --key sample.txt ./sample.txt --region {my-region} + cat sample.txt + ``` + + +## Cleanup + +1. Delete the content in the Amazon S3 bucket using the following command. Please *ensure* that the correct bucket name is provided to avoid accidental data loss: + ```bash + aws s3 rm s3://{BucketExpressOneZoneName} --recursive --region {my-region} + ``` + +2. To delete the resources deployed to your AWS account via AWS SAM, run the following command: + ```bash + sam delete + ``` + +--- + +Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. + +SPDX-License-Identifier: MIT-0 diff --git a/ec2-s3-express-one-zone-sam/example-pattern.json b/ec2-s3-express-one-zone-sam/example-pattern.json new file mode 100644 index 000000000..4bed5733a --- /dev/null +++ b/ec2-s3-express-one-zone-sam/example-pattern.json @@ -0,0 +1,58 @@ +{ + "title": "Amazon EC2 to Amazon S3 Express One Zone directory bucket", + "description": "SAM Template that creates an EC2 Instance, an Amazon S3 Express One Zone directory bucket and required IAM Role to access the bucket from the instance", + "language": "YAML", + "level": "200", + "framework": "SAM", + "introBox": { + "headline": "How it works", + "text": [ + "Both Amazon EC2 Instance and Amazon S3 Express One Zone directory bucket are provisioned within same availability zone.", + "Access to the directory bucket from the EC2 instance is provided through IAM Role associated with the instance profile." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/ec2-s3-express-one-zone-sam", + "templateURL": "serverless-patterns/ec2-s3-express-one-zone-sam", + "projectFolder": "ec2-s3-express-one-zone-sam", + "templateFile": "template.yaml" + } + }, + "resources": { + "bullets": [ + { + "text": "Amazon S3 User Guide", + "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-one-zone.html" + }, + { + "text": "AWS CLI Command Refernece", + "link": "https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html" + } + ] + }, + "deploy": { + "text": [ + "sam deploy --guided" + ] + }, + "testing": { + "text": [ + "See the GitHub repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "Delete the Amazon S3 bucket content: aws s3 rm s3://{BucketExpressOneZoneName} --recursive --region {my-region}", + "Delete the stack: sam delete." + ] + }, + "authors": [ + { + "name": "Biswanath Mukherjee", + "image": "https://d1rwvjey2iif32.cloudfront.net", + "bio": "I am a Sr. Solutions Architect working at AWS India.", + "linkedin": "biswanathmukherjee" + } + ] +} diff --git a/ec2-s3-express-one-zone-sam/images/architecture.png b/ec2-s3-express-one-zone-sam/images/architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..2d40ba1e37e84e0a7bf7665d13650d8401efda09 GIT binary patch literal 13299 zcmYj&WmsELvvo@;rO@K8C0McGPLbjcrA32laYBLOEffuI!CeZ)J-8DHQrtbbLvj1^ zzR$hS{r*JGkG*G4)|s=`nn{?3n*3WV3an?(p1oC6koolN*>foBvn3`5>h-5``5)BV zbJtJuAD@+vQ0+c@_U@UYjMV4vMu&zkzY!@CKB6)7e83ZH++U+QI&#(}z}fD{#XUNr z0){j<-{rgtp&{YJ1N0CQVBS}F@uUq~Su@Vr^W@)sFiOry+N-eM+b=0U;=VcE=*KqRE~XQx2$!Ed$0^{Pjc(*A~Sg>24czKY^`MJvV>1S_LCWOAmL|K5bo} z=>i!M(oi-parNO9C{Vf}%}A_MY;+2nSeO3Ajhc})fIcAykcp3cn4!pAgat?I&RfH~ z8|dNyBRDf9_?2G1b}{?zUE8L!8c-sV1WB!kkG}X+k_@;g3{evFTug8fOxYw*2j{BI=LD!>vgO+SwBy*>HiAqNADX5~zXUb5&cpM^?_P7czWC>rP@ z8RoYIUAhr$ivZf|93=I|%>2ph0gEew(ah1xT+Cd;l2V(#aq~<1xcYcmtdWRKd&{9_3_2btc^^s z%)2u?A%HmmkA^y86h8}(>{M~LRlU_Rplr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7W1+vbKYX zSH!;}TiuHua_maC8L2HJ`iz^~VNog(zhF~_rZYYk5B(R+fG>&BOdIQMAM`8OKC6YM z7Pu=BapZsZF|4tY+PLLsya3`me41C60p@-zzd;c9gh6 z##VuuAMg*C?s%c(jMYByH~GCDsb!(qU(G0UWveeMsFUls#JeEyA2e90Q$#GrI?M=J zEh@2;!o1+i-tBCYhzv0(esZ$S+pm`vbm6&vh;pnNZM|5rhwYXFK_PN2?z8&1=#J4d zBLadu+^n9=z<%eA%MTcDVC4n^#nCIxZYIF5)c_eC!q$-5dbXpV__33hes`}hs!xpc z`?GC0&-^sVQ)fTD!}ruocoD2Hqe>}3<-gL{4Y$1RFxpv=t_0nqp;bB0=^uzYM;K20 zx*mNwF)MO%5X4rsRdE>pypW$508LJ=xbC*2a5dD-9pHIMqj_Ctn=7uK(V76;>y>dB zO5u^K5?CtOHVK}Y5Z#_ljkJNq>_gbeS#El6ZALZLgut2(S)p<4(k!iZ4wgarwN44t zx8k%Cbblc6UF}7PKXTLwxP)GzrK%`J|o0RuqH{4rzD zvx$!$)9j~5 z0PF);gfm<+!UF+x4SGlEb9G*#ziGn3HC0ssb|j>&>e#Vy>a;^~c^+RD1hHT{6T+F$ r|0=S42DCxsN6O!xO62H|xH)Ve%DvM4(NX{6d8R0 /var/www/html/index.html + Tags: + - Key: Name + Value: !Sub "EC2-Instance-${AvailabilityZoneName}" + + + # Create an Amazon S3 Express One Zone storage class bucket + BucketExpressOneZone: + Type: AWS::S3Express::DirectoryBucket + Properties: + # BucketName: input-bucket-express-one-zone + DataRedundancy: SingleAvailabilityZone + LocationName: !Sub "${AvailabilityZoneId}" + + # OutputBucketExpressOneZone: + # Type: AWS::S3Express::DirectoryBucket + # Properties: + # # BucketName: input-bucket-express-one-zone + # DataRedundancy: SingleAvailabilityZone + # LocationName: !Sub "${AvailabilityZoneId}" + +# Output EC2 ARN, Bucket names +Outputs: + EC2InstanceId: + Value: !Ref EC2Instance + BucketExpressOneZoneName: + Value: !Ref BucketExpressOneZone From 36246794bbe3b221d30f76f8cdcf1a3e2c928115 Mon Sep 17 00:00:00 2001 From: Biswanath Mukherjee Date: Sat, 3 Feb 2024 20:57:48 +0530 Subject: [PATCH 2/4] Fixed review comment --- ec2-s3-express-one-zone-sam/template.yaml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/ec2-s3-express-one-zone-sam/template.yaml b/ec2-s3-express-one-zone-sam/template.yaml index 7dd78e517..199d17994 100644 --- a/ec2-s3-express-one-zone-sam/template.yaml +++ b/ec2-s3-express-one-zone-sam/template.yaml @@ -73,7 +73,12 @@ Resources: - CidrIp: 0.0.0.0/0 IpProtocol: tcp FromPort: 22 - ToPort: 22 + ToPort: 22 + SecurityGroupEgress: + - IpProtocol: all + CidrIp: 0.0.0.0/0 + + # Create EC2 Instance Profile, Role EC2InstanceProfile: @@ -158,14 +163,6 @@ Resources: SubnetId: !Ref Subnet GroupSet: - !Ref SecurityGroup - # UserData: - # Fn::Base64: | - # #!/bin/bash - # yum update -y - # yum install -y httpd - # systemctl start httpd - # systemctl enable httpd - # echo "Hello World from $(hostname -f)" > /var/www/html/index.html Tags: - Key: Name Value: !Sub "EC2-Instance-${AvailabilityZoneName}" @@ -179,12 +176,6 @@ Resources: DataRedundancy: SingleAvailabilityZone LocationName: !Sub "${AvailabilityZoneId}" - # OutputBucketExpressOneZone: - # Type: AWS::S3Express::DirectoryBucket - # Properties: - # # BucketName: input-bucket-express-one-zone - # DataRedundancy: SingleAvailabilityZone - # LocationName: !Sub "${AvailabilityZoneId}" # Output EC2 ARN, Bucket names Outputs: From 39fecead5adae1b4b1c75373897943e9a96f3e8f Mon Sep 17 00:00:00 2001 From: Biswanath Mukherjee Date: Sat, 10 Feb 2024 18:46:23 +0530 Subject: [PATCH 3/4] Fixed review comment --- ec2-s3-express-one-zone-sam/.gitignore | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 ec2-s3-express-one-zone-sam/.gitignore diff --git a/ec2-s3-express-one-zone-sam/.gitignore b/ec2-s3-express-one-zone-sam/.gitignore deleted file mode 100644 index dbb0539c9..000000000 --- a/ec2-s3-express-one-zone-sam/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# SAM default build folder -.aws-sam/ - -# macOS -*.DS_Store - -#VS Code -.vscode/ From 17f5bb35d25d609ff0f44a1ca9840aaf1cf42366 Mon Sep 17 00:00:00 2001 From: Udit Parikh Date: Thu, 15 Feb 2024 18:01:45 +0530 Subject: [PATCH 4/4] Added ec2-s3-express-one-zone-sam.json --- .../ec2-s3-express-one-zone-sam.json | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 ec2-s3-express-one-zone-sam/ec2-s3-express-one-zone-sam.json diff --git a/ec2-s3-express-one-zone-sam/ec2-s3-express-one-zone-sam.json b/ec2-s3-express-one-zone-sam/ec2-s3-express-one-zone-sam.json new file mode 100644 index 000000000..ceb2a8801 --- /dev/null +++ b/ec2-s3-express-one-zone-sam/ec2-s3-express-one-zone-sam.json @@ -0,0 +1,78 @@ +{ + "title": "Amazon EC2 to Amazon S3 Express One Zone directory bucket", + "description": "SAM Template that creates an EC2 Instance, an Amazon S3 Express One Zone directory bucket and required IAM Role to access the bucket from the instance", + "language": "YAML", + "level": "200", + "framework": "SAM", + "introBox": { + "headline": "How it works", + "text": [ + "S3 Express One Zone is the first S3 storage class that gives you the option to co-locate high-performance object storage and AWS compute resources, such as Amazon Elastic Compute Cloud, Amazon Elastic Kubernetes Service, and Amazon Elastic Container Service, within a single Availability Zone.", + "Here, we provisioned both the Amazon EC2 instance and the S3 Express One Zone Directory bucket within same availability zone. We will perform both read and write opertation from the directory bucket from within the EC2 instance and outside.", + "Both Amazon EC2 Instance and Amazon S3 Express One Zone directory bucket are provisioned within same availability zone.", + "Access to the directory bucket from the EC2 instance is provided through IAM Role associated with the instance profile." + ] + }, + "gitHub": { + "template": { + "repoURL": "https://github.com/aws-samples/serverless-patterns/tree/main/ec2-s3-express-one-zone-sam", + "templateURL": "serverless-patterns/ec2-s3-express-one-zone-sam", + "projectFolder": "ec2-s3-express-one-zone-sam", + "templateFile": "template.yaml" + } + }, + "resources": { + "bullets": [ + { + "text": "Amazon S3 Express One Zone User Guide", + "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-express-one-zone.html" + }, + { + "text": "AWS CLI Command Refernece", + "link": "https://docs.aws.amazon.com/cli/latest/reference/s3api/put-object.html" + } + ] + }, + "deploy": { + "text": [ + "sam deploy --guided" + ] + }, + "testing": { + "text": [ + "See the GitHub repo for detailed testing instructions." + ] + }, + "cleanup": { + "text": [ + "Delete the Amazon S3 bucket content: aws s3 rm s3://{BucketExpressOneZoneName} --recursive --region {my-region}", + "Delete the stack: sam delete." + ] + }, + "authors": [ + { + "name": "Biswanath Mukherjee", + "image": "https://d1rwvjey2iif32.cloudfront.net", + "bio": "I am a Sr. Solutions Architect working at AWS India.", + "linkedin": "biswanathmukherjee" + } + ], + "patternArch": { + "icon1": { + "x": 20, + "y": 50, + "service": "ec2", + "label": "Amazon EC2" + }, + "icon2": { + "x": 80, + "y": 50, + "service": "s3", + "label": "Amazon S3 Express One Zone" + }, + "line1": { + "from": "icon1", + "to": "icon2" + } + } +}