> For the complete documentation index, see [llms.txt](https://rishaws-projects.gitbook.io/devops-project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rishaws-projects.gitbook.io/devops-project/aws-infrastructure-automation-with-terraform-and-github-action..md).

# AWS Infrastructure Automation with Terraform and Github Action.

<figure><img src="https://2235342820-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fd45Ga3gpq3SIyF346KGX%2Fuploads%2FYE15fMbpM8PGrAOnNwKU%2Fgithub_ec2.drawio%20(1).png?alt=media&amp;token=27328af1-a5fd-49c8-9ed9-7cf2daa2cc85" alt=""><figcaption><p>Overview of Project</p></figcaption></figure>

## Overview

> Series of steps that we are going to perform  in this project.
>
> 1. Create a new repository in GitHub to store your Terraform code.
>
> 2. Configure the AWS provider in the `provider.tf` file by specifying your access key and secret key as environment variables or using a credential file.
>
> 3. Write Terraform code to create your AWS infrastructure. This can include resources such as EC2 instances, S3 buckets, RDS databases, VPCs, etc.
>
> 4. Set up a GitHub Actions workflow to run Terraform `init`, `plan`, and `apply` commands. Use `hashicorp/setup-terraform` action to set up Terraform, and `actions/checkout` action to clone your repository.
>
> 5. Save the Terraform state file using `actions/upload-artifact` action so that it can be used by the `terraform destroy` workflow.
>
> 6. Add environment variables for your AWS access key and secret key to your GitHub repository secrets to keep them secure.
>
> 7. Run the GitHub Actions workflow to create your infrastructure. You can use the Terraform output to get the URLs or IPs of the resources created.
>
> 8. When you are done with your infrastructure, run the `terraform destroy` command using a separate GitHub Actions workflow. You can use `actions/download-artifact` action to download the Terraform state file from the `terraform apply` workflow. This workflow should only run on manual triggers and prompt the user for confirmation before destroying the infrastructure.

> By automating your infrastructure with Terraform and GitHub Actions, you can easily spin up and tear down your AWS resources, and keep your infrastructure as code in version control. This makes it easy to collaborate with others and maintain a history of changes to your infrastructure over time.

## Quick links

{% content-ref url="/pages/wzjnRtZtkWZJWWXzMLip" %}
[Terraform Code](/devops-project/initial/terraform-code.md)
{% endcontent-ref %}

{% content-ref url="/pages/1R94S4g6PInfcRh8Jsgm" %}
[Push code to Github Repo](/devops-project/initial/push-code-to-github-repo.md)
{% endcontent-ref %}

## Get Started

We've put together some helpful guides for you to get setup with our product quickly and easily.

{% content-ref url="/pages/E0iEoV9IRXdQpsRPAA1Q" %}
[Trigger Workflow](/devops-project/results/trigger-workflow.md)
{% endcontent-ref %}

{% content-ref url="/pages/S0cJUiUCZBPRuE0JXP9m" %}
[Phase 1 - Github Action](/devops-project/setup-ci-cd/phase-1-github-action.md)
{% endcontent-ref %}

{% content-ref url="/pages/PSn45dylPtFUpyp1C09a" %}
[Check Infrastructure](/devops-project/results/check-infrastructure.md)
{% endcontent-ref %}
