aplacaba / go-cloudformation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoWebServer

Deploy web infrastracture for a hello world go app in AWS

How To Use

Cloudformation

To build infra, first we have to set the environment variables needed to run the scripts

export VPC_ID=
export CLUSTER_NAME=
export STACK_NAME=

Next we’ll make use of the helper scripts to run the cloudformation script

Scripts

./scripts/create-stack

Creates the cloudformation stack

./scripts/update-stack

Updates the cloudformation stack

./scripts/cleanup

Deletes the stack

Run the create stack script

./scripts/create-task

Github Actions

Once cloud formation has completed. We can now have access to the Role ARN on the outputs. Define GHA_ROLE_ARN on actions secrets or change this line on main.yml

role-to-assume: <your-arn>

Now that arn is set we can trigger the build pushing a commit

touch sample.txt
git commit -am "sample"

Update the Stack

Once the workflow is done without failures.

We need to update the service DesiredCount to a value greater than 0

ECSService:
  Properties:
    ...
    DesiredCount: 1

then update the stack

./scripts/update-stack

Access the app

On update stack complete, go to outputs tab and copy the loadbalancer dns name.

Cleanup

Run the ./scripts/cleanup

if cleanup fails delete the repository on aws console and run the script again

About


Languages

Language:Shell 47.9%Language:Go 37.2%Language:Dockerfile 14.9%