DEV Community

Cover image for Mythical Mysfits
jicoing
jicoing

Posted on • Edited on

Mythical Mysfits

About

A tutorial for developers that want to learn about how to build modern applications on top of AWS. We build a sample website that leverages infrastructure as code, containers, serverless code functions, CI/CD, and more.
Github: https://github.com/aws-samples/aws-modern-application-workshop/tree/python

Architecture

Alt Text

S3 web hosting with CloudFront and OAI

1. Cloned git repository
Alt Text

2. Git checkout branch python in VSCode
Alt Text

3. S3 bucket created
Alt Text

4. Index.html uploaded from github source code to S3.
Alt Text

5. Static website hosted in S3 bucket
Alt Text

6. Bucket policy changed
Alt Text

7. Static website is accessible from the URL endpoint
Alt Text

Cloudfront

Alt Text

8. Cloudfront distribution created
Alt Text
Alt Text

9. OAI created to restrict bucket access to Cloudfront user.
Alt Text

Alt Text

10. Bucket policy automatically updated to retrict access to only OAI
Alt Text

11. Verified the bucket is only accessible to OAI
Alt Text

Note:

If you are getting CloudFront Error: This XML file does not appear to have any style information associated with it [duplicate]
go to Cloud front -> Select you cloud distribution detail -> select tab General -> Select edit -> In this form Setup the property Default Root Object to index.html
Ref: https://stackoverflow.com/questions/44741287/cloudfront-error-this-xml-file-does-not-appear-to-have-any-style-information-as
Alt Text

Cloud9 - Secure static web hosting

In this module, we create a cloud-based IDE on AWS Cloud9 and deploy the first version of the static Mythical Mysfits website.

1. Cloned the git repository into Cloud9
Alt Text

2. Bucket created with CLI
Alt Text

3. Static website and Bucket policy added with CLI
Alt Text

4. index.html uploaded from module-1 to bucket
Alt Text

5. Website is visible - http://mythical-misfitfrontend.s3-website-us-east-1.amazonaws.com/
Alt Text

Creating the Core Infrastructure using AWS CloudFormation

1. create-stack from Cloud9
Alt Text

Describe stack
Alt Text

Created
Alt Text

Deploying a Service with AWS Fargate

1. Navigate to ~/environment/module-2/app
Alt Text

2. Build the docker image
Alt Text

3. Testing the Service Locally
Alt Text

Preview JSON response from running service
Alt Text

Pushing the Docker Image to Amazon ECR

1. ECR repository created
Alt Text

Alt Text

2. Login
Alt Text

3. Docker push to ECR
Alt Text

Alt Text

4. Describe image
Alt Text

Configuring the Service Prerequisites in Amazon ECS

1. Create ECS cluster
Alt Text

Alt Text

2. Task definition update
Alt Text

3. Task definition registered
Alt Text
Alt Text

Enabling a Load Balanced Fargate Service

1. Provision a new NLB
Alt Text

nlb.json
Alt Text

2. Create target group
Alt Text

target-group.json
Alt Text

3. Create listener
Alt Text

Console

Load balancer/Listeners
Alt Text

Target group
Alt Text

4. Updated service-definition.json
Alt Text

5. ECS service created
Alt Text

Service running in cluster
Alt Text

Alt Text

Testing the service

1. DNS copied from nlb-output.json
Alt Text

2. Running from browser to get json response
Alt Text

Updating frontend

1. index.html API Endpoint updated to NLB DNS
Alt Text

2. Updated index.html copied to S3 bucket - mythical-misfitfrontend
Alt Text

Verify S3 static website URL

Alt Text

Request going out to ELB DNS from static website URL
Alt Text

Alt Text

Frontend connected to backend container through the load balancer!

Alt Text

Automating Deployments using AWS Code Services

1. Creating a new bucket for artifacts
Alt Text

2. Updated artifacts bucket policy
Alt Text
Alt Text

3. Grant access to this bucket to your CI/CD pipeline
Alt Text

4. Create Code-Commit repository
Alt Text
Alt Text

5. Create code-build project
Alt Text

Alt Text

Create pipeline in Codepipeline

1. Update codepipeline.json
Alt Text

`2. Create codepipeline
Alt Text
Alt Text

3. Updated ECR policy
Alt Text

4. Enable Automated Access to ECR Image Repository
Alt Text

Test the CI/CD Pipeline

1. Configure git and clone
Alt Text

2. Copied the application files to ythicalMysfitsService-Repository
Alt Text

3. Run git commands to push in your code changes
Alt Text

4. CodePipeline in action on git push
Alt Text

Automated Deployment - Testing a code change in mysfits-response.json

Before
Alt Text

Change in mysfits-response.json
Alt Text

git push
Alt Text

CodePipeline triggered
Alt Text

After
Alt Text

Adding a Data Tier with Amazon DynamoDB

Alt Text

Create table with CLI
Alt Text

Table scan shows empty table
Alt Text

Website bucket updated with new URL
Alt Text

Top comments (0)