Skip to content

Commit

Permalink
Add terraform import
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrett committed Oct 9, 2023
1 parent 1a07943 commit 8b6f15a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/tf-azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,25 @@ jobs:
jq 'with_entries(.key |= ascii_downcase)' tmp-secrets.json > web-secrets.auto.tfvars.json
jq 'with_entries(.key |= ascii_downcase)' tmp-vars.json > web-vars.auto.tfvars.json
- name: Terraform import
id: tf-import
run: >
terraform import azurerm_resource_group.rg /subscriptions/***/resourceGroups/s195d01-hfeyp-rg
# Generates an execution plan for Terraform
# An exit code of 0 indicated no changes, 1 a terraform failure, 2 there are pending changes.
- name: Terraform Plan
id: tf-plan
run: |
export exitcode=0
terraform plan -detailed-exitcode -no-color -out tfplan || export exitcode=$?
echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
if [ $exitcode -eq 1 ]; then
echo Terraform Plan Failed!
exit 1
else
else
exit 0
fi
Expand All @@ -104,7 +109,7 @@ jobs:
id: tf-plan-string
run: |
TERRAFORM_PLAN=$(terraform show -no-color tfplan)
delimiter="$(openssl rand -hex 8)"
echo "summary<<${delimiter}" >> $GITHUB_OUTPUT
echo "## Terraform Plan Output" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -162,6 +167,11 @@ jobs:
jq 'with_entries(.key |= ascii_downcase)' tmp-secrets.json > web-secrets.auto.tfvars.json
jq 'with_entries(.key |= ascii_downcase)' tmp-vars.json > web-vars.auto.tfvars.json
- name: Terraform import
id: tf-import
run: >
terraform import azurerm_resource_group.rg /subscriptions/***/resourceGroups/s195d01-hfeyp-rg
# Download saved plan from artifacts
- name: Download Terraform Plan
uses: actions/download-artifact@v3
Expand All @@ -171,4 +181,4 @@ jobs:

# Terraform Apply
- name: Terraform Apply
run: terraform apply -auto-approve tfplan/tfplan
run: terraform apply -auto-approve tfplan/tfplan

0 comments on commit 8b6f15a

Please sign in to comment.