-
Notifications
You must be signed in to change notification settings - Fork 0
HelloWorld Serverless
Iain Hunter edited this page Sep 9, 2019
·
9 revisions
The helloWorld app demonstates how we can upload a docker container to AWS and run it on a cron-like schedule
We can create our VPC by running the following:
cd /ops/terraform/global/vpc
tfinit
terraform apply
Our app is going to need permissions to setup and use our serverless infrastructure on Amazon Fargate, here we just create the necessary roles and policies
cd /ops/terraform/global/iam
tfinit
terraform apply
We now need to create the infrastructure for our app to sit on
cd /ops/terraform/apps/fargate_hello
tfinit
terraform apply
- You can clone the app from https://github.com/hunt3ri/fargate-hello
- To build
docker-compose up - Note you'll need to modify the Slack web hook if you want to play with it yourself.
Finally we need to push our container to the cloud:
- The output of Step 3 will include the URL of the ECR repo eg
YOUR-ACCOUNT-ID.dkr.ecr.us-east-1.amazonaws.com/fargate-hello - You now need to tag the local fargate-hello container using a special format so it can be uploaded to AWS:
docker tag fargate_hello:latest YOUR-ACCOUNT-ID.dkr.ecr.us-east-1.amazonaws.com/fargate-hello:latest- From the terraform container we need to get a login so we can push the container to AWS:
aws ecr get-login --no-include-email- Copy and paste the output and run it on the command line we can login to AWS ECR
- Finally we can push the image to AWS
docker push YOUR-ACCOUNT-ID.dkr.ecr.us-east-1.amazonaws.com/fargate-hello:latest
We can remove all infrastructure by running the following
cd /ops/terraform/apps/fargate_hello
terraform destroy
cd /ops/terraform/global/iam
terraform destroy
cd /ops/terraform/global/vpc
terraform destroy