Skip to content

jemsallen/terraform-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-automation

Terraform Cloud <-> Github <-> AWS automation demo

This is a demo repository to demonstrate GitOps automation using Terraform Cloud and Terraform for provisioning AWS resources.

Pre-requisites

Setup Instructions

Steps

Authentication setup

1. Terraform Cloud <-> Github

Setup OIDC between Terraform Cloud and Github using Github and Terraform Cloud apps (Official documentation)

2. Terraform Cloud <-> AWS

Setup authentication between Terraform Cloud and AWS (Official documentation):

  • Create an Identity Provider (OIDC)
  • Create and assign IAM role to Identity Provider ( OIDC)
  • Configure Terraform Cloud environment variables to assume newly created role:
    • TFC_AWS_RUN_ROLE_ARN: arn:aws:iam::$accountid:role/$rolename
    • TFC_AWS_PROVIDER_AUTH: true

Configuration

  1. Configure Terraform Cloud workspace:
    • Execution mode: Remote
    • Automatic speculative plans: yes
    • VCS branch: main
  2. Configure Github repository:
    • Branch protection rule:
      • main branch - require a pull request before merging

Deployment Workflow

  • New pull requests will trigger a Terraform plan against the Github PR branch.
  • Merging a branch to main will trigger a Terraform plan (against the main branch) and prompt a user to approve the Terraform apply in Terraform Cloud.

Terraform Docs

Requirements

No requirements.

Providers

Name Version
aws n/a

Modules

No modules.

Resources

Name Type
aws_s3_bucket.this resource
aws_s3_bucket_acl.this resource
aws_s3_bucket_ownership_controls.this resource
aws_s3_bucket_versioning.this resource

Inputs

Name Description Type Default Required
bucket_config Bucket configuration map(string) n/a yes
demo-bucket-name Bucket name string n/a yes
environment Environment name string n/a yes

Outputs

No outputs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages