{"id":22442086,"url":"https://github.com/colinbut/microservice-aws-ec2-setup","last_synced_at":"2026-04-10T07:53:56.093Z","repository":{"id":69158419,"uuid":"215655575","full_name":"colinbut/microservice-aws-ec2-setup","owner":"colinbut","description":"Infrastructure provisioning of AWS EC2 instances using Terraform, Cloudformation, AWS Console, aws cli","archived":false,"fork":false,"pushed_at":"2020-05-12T10:31:23.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T14:46:13.342Z","etag":null,"topics":["aws","aws-cli","aws-cloudformation","awscli","cloudformation","devops","ec2","ec2-instance","hcl","python","python-3","python3","shell","shell-script","shell-scripting","shell-scripts","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colinbut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-16T22:27:31.000Z","updated_at":"2020-05-12T10:31:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"5675f9cf-3e38-442f-b981-7a5f80fc39bb","html_url":"https://github.com/colinbut/microservice-aws-ec2-setup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fmicroservice-aws-ec2-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fmicroservice-aws-ec2-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fmicroservice-aws-ec2-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colinbut%2Fmicroservice-aws-ec2-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colinbut","download_url":"https://codeload.github.com/colinbut/microservice-aws-ec2-setup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245823318,"owners_count":20678173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-cli","aws-cloudformation","awscli","cloudformation","devops","ec2","ec2-instance","hcl","python","python-3","python3","shell","shell-script","shell-scripting","shell-scripts","terraform"],"created_at":"2024-12-06T02:17:51.978Z","updated_at":"2026-04-10T07:53:51.073Z","avatar_url":"https://github.com/colinbut.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Microservice AWS EC2 Setup\n\nThis project provides the steps/methods required for setup an EC2 instance for running the microservice as defined in the [microservice-aws-demo](https://github.com/colinbut/microservice-aws-demo.git) project.\n\nThe microservice can be a containerized or a non-containerized microservice.\nSee [microservice-java](https://github.com/colinbut/microservice-java.git) \u0026 [microservice-nodejs](https://github.com/colinbut/microservice-nodejs.git) projects for more details on this.\n\nThere are many ways to setup EC2 instances in AWS:\n\n1) via __AWS mamagement console__ creating from scratch\n2) using Infrastructure as Code tool (__Terraform/Cloudformation__)\n3) __AWS CLI__\n4) utilizing a pre-build custom made __AMI__ for any of above methods\n\n## Assumptions\n1. Assumes a AWS account created and AWS credentials configured (access_keys \u0026 secret_keys etc)\n\n2. This project will create EC2 instances in the default VPC.\n\n3. To put in a custom non-default VPC require to create the custom non-default VPC.\nSee my Terraform project - [aws-public-private-vpc](https://github.com/colinbut/aws-public-private-vpc) for more reference on to create this. \n\n## Option 1 - AWS Management Console\n\nFollow the official AWW guide from AWS documentation - https://docs.aws.amazon.com/efs/latest/ug/gs-step-one-create-ec2-resources.html\n\n## Option 2 - Terraform/Cloudformation\nIt is good to manage infrastructure changes and define them in 'code'. This option details how to do this via modern infrastructure as code tools such as __Terraform__ and __AWS Cloudformation__\n\n#### Terraform \nCreate S3 bucket to store terraform state. Need to ensure bucket is unique and also ideally within same region you want to provision your infrastructure resources onto.\n\n```bash\naws s3 mb s3://[name of bucket] --region [region]\n```\n\nInitialize Terraform Backend\n```bash\nterraform init\n```\n\nValidating the terraform configuration files syntax is correct:\n```bash\nterraform validate\n```\n\nWhen make changes it is always a good idea to run `terraform plan` to check the changes are what you intend to make... even though `terraform apply` does prompt you confirm (if run without the `--auto-approve` option)\n```bash\nterraform plan\n```\n\nTo apply your infrastructure changes (creation/modifications)\n```bash\nterraform apply\n```\n\n#### Cloudformation\n\nGo to the Cloudformation directory and execute following command from the AWS CLI:\n\n```bash\naws cloudformation create-stack --stack-name microservice-ec2-instance --template-body file://ec2_instances.yml --parameters ParameterKey=KeyName,ParameterValue=MyLondonKP\n```\n\nthe --stack-name you can provide anything.\n\n## Option 3 - AWS CLI\n\nCan also create the required EC2 instances via the __AWS CLI__\n\nThere's a pre-made `create_ec2_instances` script (available in both Bash \u0026 Python) that wraps around the AWS CLI command call. To use:\n\n```bash\ncreate_ec2_instances.sh\n```\n\nor using Python:\n```python\npython create_ec2_instances.py\n```\n\nThe scripts basically just does the following aws cli command underneath the hood:\n\n```bash\naws ec2 run-instances --image-id [ami-id] --count 1 --instance-type t2.micro --key-name [KeyPair Name] --user-data [provisioning script]\n```\n\n## Option 4 - from pre-build custom made AMI\n\nSee the [microservice-ami](https://github.com/colinbut/microservice-ami.git) project for more details on the corresponding AMIs for the required development platform.\n\nPossible to uses Packer to build the AMI.\n\nTo build \u0026 deploy to your AWS account:\n\ne.g. \n```bash\npacker build [microservice-*.json]\n``` \n\nThe AMI can now be referenced in any of the above 3 methods of creating the EC2 instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fmicroservice-aws-ec2-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolinbut%2Fmicroservice-aws-ec2-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolinbut%2Fmicroservice-aws-ec2-setup/lists"}