Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ari-hacks/terraform-aws-automation
⚙️ Examples of provisioning AWS resources with Terraform
https://github.com/ari-hacks/terraform-aws-automation
aws aws-cli ec2 hcl iac iam iam-policies infrastructure-as-code infrastructure-automation s3-bucket terraform terraform-aws terraform-cli
Last synced: 18 days ago
JSON representation
⚙️ Examples of provisioning AWS resources with Terraform
- Host: GitHub
- URL: https://github.com/ari-hacks/terraform-aws-automation
- Owner: ari-hacks
- License: mit
- Created: 2020-07-21T07:34:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T08:08:53.000Z (over 4 years ago)
- Last Synced: 2024-11-15T09:41:15.819Z (3 months ago)
- Topics: aws, aws-cli, ec2, hcl, iac, iam, iam-policies, infrastructure-as-code, infrastructure-automation, s3-bucket, terraform, terraform-aws, terraform-cli
- Language: HCL
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Automating AWS with Terraform
- [x] [Launch an ec2 instance](/launch-ec2-instance)
- [X] [Create an s3 bucket](/create-s3-bucket)
- [x] [Create an s3 backend state](/create-s3-backend-state)
- [X] [Create an IAM group and policy](/create-iam-group-policy)
- [x] [Add users to an IAM group](/add-users-to-iam-group)
## External Resources
[Amazon EC2 AMI Locator](https://cloud-images.ubuntu.com/locator/ec2/)## Pre-requisite Setup
#### AWS Account - Free Tier
- [Sign up](https://aws.amazon.com/free) for AWS Free Tier account if you do not already have one
#### Create an IAM user
1. Log into your root AWS account
2. Select Services > IAM
3. On the left nav bar select 'Users'
4. Select 'Add user'
5. Create a username 'terraform-admin'
6. Select AWS access type as Programmatic access (and AWS management console access to view resources on the dashboard)
7. Select Next: Permissions
8. Select Create group
9. Add a group name 'admins'
10. Check AdministratorsAccess and Create group, check group
11. Select Next: Tags
12. Select Next: Review
13. Select Create User
14. You will need the generated access key Id, and the secret access key (Download the csv provided or store these values)
#### AWS CLI installation
1. mac: `brew install awscli` | `aws --version`
2. windows: [instructions](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-windows.html)
3. linux: [instructions](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html)#### AWS CLI configuration
aws credentials configured locally
these credentials are stored in `~/.aws/credentials`
```
aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: us-east-1
Default output format [None]: json
```
#### Terraform installation
1. mac: `brew install terraform` | `terraform -help`
2. windows: `choco install terraform` | `terraform -help`
3. linux: [download](https://www.terraform.io/downloads.html) | `echo $PATH` | ` mv ~/Downloads/terraform /usr/local/bin/` | `terraform -help`## Local Setup
clone the repo and navigate to the directory
```
git clone https://github.com/ari-hacks/terraform-aws-automation.git
cd terraform-aws-automation
```In the terminal `cd` into one of the directories from the list above
Run these commands to provision with Terraform
```HCL
#Initialize Terraform
terraform init
``````HCL
#Check the plan to make sure the configuration will do what we expect it to do
terraform plan
``````HCL
#Apply the execution plan and build the stack
terraform apply
``````HCL
#Check the resource is up
terraform state list
terraform state show 'type.name'
``````HCL
#Tear down all provisions
terraform destroy
```