generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reusable GHA for Terraform deploy #323
Merged
Merged
Changes from 68 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
414cf6c
saving reusable actions
3b42fba
tf deploy
819ee60
started docker reusablity
8cbbcd4
Merge branch 'main' into reusable-actions-combine-frontend-api
31d06bc
init
0af8c27
token
48d9557
registry
2b5c20d
version
e819775
try outcomes
f4a0e5d
try outcomes
fc7655c
try outcomes
aa24451
try outcomes
3c1f03a
try outcomes
6feb648
rm inspect
9a4f9c7
put auth prior
e3e1ac4
use cli
0cca9ed
s
0cba12e
with permissions
384fb60
with permissions
140e284
with permissions
8828fc5
move to frontend
4d3ce26
move to frontend
f19caca
use dist dir
e26081f
wip
ea2beaf
load vars
9bd6f38
build front and back together
0d10bdf
clean-up
d0df97b
Merge branch 'main' into reusable-actions-combine-frontend-api
d2cde09
clean-up
8163469
test clean-up
6cc1cdb
worked
64aea5a
clean more
5615032
Merge branch 'main' into reusable-gha-tf-deploy
1fdc4db
wip
19951a8
Terraform variable clean-up and creation
9b4f06f
wip
177b380
-
57f567d
add different env configs for state
cb0f281
Merge branch 'add-var-to-tf' into reusable-gha-tf-deploy
45a1c15
try az app service action without publish secret
5d45bea
permissions
06861a2
change app name
fa7a96a
try without login
02774d5
try building dev2 from action
f57a2df
try global env
bf48dc7
inherit
40ae68e
use login at a higher level
4374feb
wip
f4e39be
moved everything to base
324427b
use environment...
c09540f
wip
1ac85b8
oidc true
5ef2bc5
oidc true
6d88c34
wip
4be6671
rm unused vars
953c5ca
rm unused vars
6970e7b
make cidr different for each env
31a2e52
make cidr different for each env
60df27e
make cidr different for each env
02c9993
remove path thing
5e3f960
add back api to path
f584c90
revert network vars
bc05ad5
wipe
cfde56a
wip
d4494db
clean-up for merge
ecea674
Merge branch 'main' into reusable-gha-tf-deploy
61d0ffc
tab state config files to the left
fcdfeeb
ft fmt
f6dfb74
add back var in old workflow
ab6e0ea
gitignore tf lock
14a75d3
gitignore tf lock
c2f603f
gitignore tf lock
0c9042e
gitignore tf lock
9a6cbcc
gitignore tf lock
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Setup Environment with Terraform | ||
description: This action sets up the given environment using Terraform. | ||
inputs: | ||
deploy-env: | ||
description: The environment to deploy to. | ||
required: true | ||
azure-resource-group: | ||
description: The Azure Resource Group for this environment. | ||
required: true | ||
azure-client-id: | ||
description: The Azure client_id for this environment. | ||
required: true | ||
azure-tenant-id: | ||
description: The Azure tenant_id for this environment. | ||
required: true | ||
azure-subscription-id: | ||
description: The Azure subscription_id for this environment. | ||
required: true | ||
app-name: | ||
description: The name of the application being deployed in Terraform. | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Load input variables | ||
working-directory: ./ops/terraform | ||
shell: bash | ||
env: | ||
RESOURCE_GROUP_NAME: ${{ inputs.azure-resource-group }} | ||
NAME: ${{ inputs.app-name }} | ||
run: | | ||
echo resource_group_name=\""$RESOURCE_GROUP_NAME"\" >> terraform.tfvars | ||
echo name=\""$NAME"\" >> terraform.tfvars | ||
az config set defaults.group=$RESOURCE_GROUP_NAME | ||
- name: Set environment | ||
shell: bash | ||
id: set-environment | ||
env: | ||
DEPLOY_ENV: ${{ inputs.deploy-env }} | ||
run: |- | ||
echo "tf-env=$( | ||
echo ${DEPLOY_ENV} | ||
)" >> $GITHUB_OUTPUT | ||
- name: Terraform deploy | ||
working-directory: ./ops/terraform | ||
env: | ||
ARM_CLIENT_ID: ${{ inputs.azure-client-id }} | ||
ARM_TENANT_ID: ${{ inputs.azure-tenant-id }} | ||
ARM_SUBSCRIPTION_ID: ${{ inputs.azure-subscription-id }} | ||
shell: bash | ||
run: | | ||
terraform init -backend-config=config/${{ inputs.deploy-env }}.config | ||
terraform workspace select -or-create ${{ inputs.deploy-env }} | ||
terraform plan -lock-timeout=30m | ||
terraform apply -auto-approve -lock-timeout=30m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev2.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev2.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev3.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev3.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev4.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev4.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev5.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev5.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev6.terraform.tfstate" | ||
use_oidc = true | ||
storage_account_name = "tfstaterv2024" | ||
container_name = "rv-tfstate" | ||
key = "dev6.terraform.tfstate" | ||
use_oidc = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming these are for each of the different dev environments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats correct! so with TF you can store the configuration state files either locally on our computers or a in a central location. these config files basically create and update these files in a global AZ Resource Group in the same account subscription. the benefit of separating them out into individual files like this is so we can use the
-backend-config=config/${{ inputs.deploy-env }}.config
flag in theterraform
cli. We are no using that here in a reusable GHA:ReportVision/.github/actions/tf-setup/action.yml
Line 53 in fcdfeeb
In the future however, I would like to research and find out if this is for sure the best and most appropriate way of doing this but for now, this allows for a bunch of flexibility.