Simple Website¶
Prerequisites¶
AWS account
Install the AWS CLI and Configure CLI credentials
Install the Attini CLI
Setup/Configure the Attini framework with the following command:
attini setup --accept-license-agreement --create-deployment-plan-default-role --create-init-deploy-default-role --give-admin-access
Note
This configuration gives Attini a lot of access so only do this in a sandbox accounts.
Description¶
This is a simple website busing S3 and CloudFront and a serverless backend based on API Gateway, Lambda and DynamoDB put together using SAM.
The Init deployment stack contains one Attini deployment plan and one Lambda that copies the static web content from the Attini distribution to the S3 bucket which is the source of the CloudFront distribution.
As you can see in the diagrams, we create one Lambda in the Init deployment stack. This might seem like an anti-pattern but, this Lambda is not used by an application, it is used by the deployment plan to upload website content to s3 and invalidate the CloudFront cache. Because this Lambda is a “deployment” resource, its ok to have it in the Init deployment stack. However, its also ok to have it as a step in the deployment-plan if you prefer.
CloudFormation architecture
Deployment plan
Deployment guide¶
Clone the example repository:
git clone git@github.com:attini-cloud-solutions/example-website.git
Deploy the distribution using the Attini CLI:
attini environment create test attini deploy run --environment test example-website
Note
Now we name the environment “test”, you can change this to any name you want. Keep in mind that it will affect the name of the CloudFormation stacks.
Verify the website¶
Go to CloudFront in the AWS Console
Find the CloudFront distribution with the Comment “Attini example website”
Open the CloudFront URL in your web browser
Clean up¶
Clean up using the AWS console
Empty the webasset bucket
test-webassets-bucket
Delete the CloudFormation stack
test-website
Delete the CloudFormation stack
test-backend
Delete the CloudFormation stack
test-website-init-deploy
Clean up using the AWS CLI
BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name test-website --query 'Stacks[0].Outputs[?OutputKey==`WebassetsBucket`].OutputValue' --output text) aws s3 rm "s3://$BUCKET_NAME" --recursive aws cloudformation delete-stack --stack-name test-website aws cloudformation delete-stack --stack-name test-backend aws cloudformation delete-stack --stack-name test-website-init-deploy
If you want to remove the whole Attini framework, see Deleting/Clean up the Attini framework