Skip to content

Commit

Permalink
Modules (#34)
Browse files Browse the repository at this point in the history
* added modules for tfc cloud

* updated tf readme with tf-docs

* updated create_ec2

* Updating terraform cloud workflow

* added few modifs for tfplan

* added few modifs for tfplan

* added few modifs for tfplan
  • Loading branch information
chefgs authored Jul 16, 2024
1 parent 8de916a commit 3f571d3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 11 deletions.
50 changes: 39 additions & 11 deletions .github/workflows/tf_cloud_aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

env:
tfcode_path: tfcloud_samples/amazon_ec2
Expand All @@ -34,7 +35,7 @@ jobs:

# Add the AWS Creds as ENV variable in TF Cloud workspace, since the tf run happens in TF Cloud environment

# Call rest of the Terraform commands
# Invoke the Terraform commands
- name: Terraform init and validate
run: |
echo `pwd`
Expand All @@ -44,18 +45,45 @@ jobs:
echo "** Running Terraform Validate**"
terraform validate
working-directory: ${{ env.tfcode_path }}
- name: Terraform plan and apply

- name: Terraform Plan
run: |
echo `pwd`
echo "** Running Terraform Plan**"
# terraform plan -out=tfplan
terraform plan
echo "** Running Terraform Apply**"
terraform apply -auto-approve
working-directory: ${{ env.tfcode_path }}

- name: Upload Terraform Plan
uses: actions/upload-artifact@v2
with:
name: terraform-plan
path: ${{ env.tfcode_path }}/tfplan

# Once the user verifies the Terraform Plan, the user can run the Terraform Apply and Destroy commands
apply_terraform_plan:
needs: aws_tfc_job
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Terraform CLI
uses: hashicorp/[email protected]
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Download Terraform Plan
uses: actions/download-artifact@v2
with:
name: terraform-plan
path: ${{ env.tfcode_path }}
- name: Terraform Apply
run: |
echo "** Running Terraform Apply**"
terraform apply -auto-approve tfplan
working-directory: ${{ env.tfcode_path }}

- name: Terraform Destroy
run: |
echo "** Running Terraform Destroy**"
terraform destroy -auto-approve
working-directory: ${{ env.tfcode_path }}
- name: Terraform Destroy
run: |
echo "** Running Terraform Destroy**"
terraform destroy -auto-approve
working-directory: ${{ env.tfcode_path }}
1 change: 1 addition & 0 deletions aws_samples/create_ec2/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions learn-terraform-plan
Submodule learn-terraform-plan added at 326807

0 comments on commit 3f571d3

Please sign in to comment.