Terraform apply #121
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
name: 'Terraform apply' | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
required: true | |
description: The environment to deploy against. | |
type: string | |
default: intg | |
project: | |
required: true | |
description: The project to run this for | |
type: choice | |
options: | |
- tdr | |
- dr2 | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
setup: | |
uses: nationalarchives/dr2-github-actions/.github/workflows/set_terraform_var_names.yml@main | |
with: | |
project: ${{ github.event.inputs.project }} | |
environment: ${{ github.event.inputs.environment }} | |
apply: | |
uses: nationalarchives/dr2-github-actions/.github/workflows/terraform_apply.yml@main | |
needs: setup | |
with: | |
repo-name: tna-custodian | |
environment: ${{ github.event.inputs.environment }} | |
working-directory: terraform | |
project: ${{ github.event.inputs.project }} | |
secrets: | |
WORKFLOW_TOKEN: ${{ secrets[needs.setup.outputs.workflow-token] }} | |
ACCOUNT_NUMBER: ${{ secrets[needs.setup.outputs.account-number] }} | |
SLACK_WEBHOOK: ${{ secrets[needs.setup.outputs.slack-webhook] }} | |
TERRAFORM_ROLE: ${{ secrets[needs.setup.outputs.terraform-role] }} | |
STATE_BUCKET: ${{ secrets[needs.setup.outputs.state-bucket] }} | |
DYNAMO_TABLE: ${{ secrets[needs.setup.outputs.dynamo-table] }} | |
custodian: | |
environment: ${{ github.event.inputs.project }}-${{ github.event.inputs.environment }} | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
- apply | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: ${{ secrets[needs.setup.outputs.workflow-token] }} | |
- name: Configure AWS credentials for Cloud Custodian | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
role-to-assume: ${{ secrets[needs.setup.outputs.custodian-role] }} | |
aws-region: eu-west-2 | |
role-session-name: CustodianRole | |
- run: | | |
pip install pyopenssl --upgrade | |
pip install ruamel.yaml c7n c7n-mailer c7n-guardian --ignore-installed six | |
cd accounts | |
../custodian/scripts/deploy-custodian.sh ${{ needs.setup.outputs.project-upper }} ${{ github.event.inputs.environment }} ${{ secrets[needs.setup.outputs.email] }} ${{ secrets[needs.setup.outputs.management-account] }} | |
- uses: nationalarchives/tdr-github-actions/.github/actions/slack-send@main | |
with: | |
message: | | |
Cloud Custodian deployed to ${{ github.event.inputs.environment }} AWS account | |
slack-url: ${{ secrets[needs.setup.outputs.slack-webhook] }} |