-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use OpenAPI schema to define REST API, then add logging and IAM execution permissions. Add an account-level IAM role for logging to CloudWatch. Remove lambda function URLs. Test against REST API base URL. Fixes VEGA-2014 #minor
- Loading branch information
Showing
22 changed files
with
500 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: "[Job] Plan/Deploy to Account" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
workspace_name: | ||
description: "The terraform workspace to target for account actions" | ||
required: true | ||
type: string | ||
secrets: | ||
aws_access_key_id: | ||
description: "AWS Access Key ID" | ||
required: true | ||
aws_secret_access_key: | ||
description: "AWS Secret Access Key" | ||
required: true | ||
|
||
jobs: | ||
terraform_account_workflow: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ inputs.workspace_name }} account | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: "0" | ||
- uses: unfor19/install-aws-cli-action@v1 | ||
- uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: 1.4.6 | ||
terraform_wrapper: false | ||
- name: Configure AWS Credentials For Terraform | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.aws_access_key_id }} | ||
aws-secret-access-key: ${{ secrets.aws_secret_access_key }} | ||
aws-region: eu-west-1 | ||
role-duration-seconds: 3600 | ||
role-session-name: OPGLpaStoreGithubAction | ||
|
||
- name: Lint Terraform | ||
run: terraform fmt -check -recursive | ||
working-directory: ./terraform/account | ||
continue-on-error: true | ||
|
||
- name: Terraform Init | ||
run: terraform init -input=false | ||
working-directory: ./terraform/account | ||
|
||
- name: Terraform Plan | ||
env: | ||
TF_WORKSPACE: ${{ inputs.workspace_name }} | ||
run: | | ||
terraform workspace show | ||
echo "plan_summary=$(terraform plan -no-color -lock-timeout=300s -input=false -parallelism=30 | grep -ioE 'Plan: [[:digit:]]+ to add, [[:digit:]]+ to change, [[:digit:]]+ to destroy|No changes. Your infrastructure matches the configuration.')" >> $GITHUB_OUTPUT | ||
terraform plan -lock-timeout=300s -input=false -parallelism=30 | ||
working-directory: ./terraform/account | ||
|
||
- name: Terraform Apply | ||
if: github.ref == 'refs/heads/main' | ||
env: | ||
TF_WORKSPACE: ${{ inputs.workspace_name }} | ||
run: | | ||
terraform apply -lock-timeout=300s -input=false -auto-approve -parallelism=30 | ||
working-directory: ./terraform/account |
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
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
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,6 @@ | ||
# Terraform | ||
export TF_WORKSPACE=development | ||
export TF_VAR_default_role=operator | ||
export TF_VAR_management_role=operator | ||
|
||
export TF_CLI_ARGS_init="-backend-config=role_arn=arn:aws:iam::311462405659:role/operator" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
resource "aws_iam_role" "api_gateway_cloudwatch" { | ||
name = "api-gateway-cloudwatch-global" | ||
assume_role_policy = data.aws_iam_policy_document.api_gateway_assume_role.json | ||
} | ||
|
||
data "aws_iam_policy_document" "api_gateway_assume_role" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["apigateway.amazonaws.com"] | ||
} | ||
} | ||
} | ||
|
||
resource "aws_iam_role_policy_attachment" "api_gateway_log_to_cloudwatch" { | ||
role = aws_iam_role.api_gateway_cloudwatch.id | ||
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" | ||
} |
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,31 @@ | ||
terraform { | ||
backend "s3" { | ||
bucket = "opg.terraform.state" | ||
key = "opg-data-lpa-deed-account/terraform.tfstate" | ||
encrypt = true | ||
region = "eu-west-1" | ||
role_arn = "arn:aws:iam::311462405659:role/lpa-store-ci" | ||
dynamodb_table = "remote_lock" | ||
} | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.8.0" | ||
} | ||
} | ||
required_version = ">= 1.4.0" | ||
} | ||
|
||
provider "aws" { | ||
region = "eu-west-1" | ||
|
||
assume_role { | ||
role_arn = "arn:aws:iam::${local.account.account_id}:role/${var.default_role}" | ||
session_name = "terraform-session" | ||
} | ||
|
||
default_tags { | ||
tags = local.default_tags | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"accounts": { | ||
"development": { | ||
"account_id": "493907465011", | ||
"account_name": "development", | ||
"is_production": false | ||
} | ||
} | ||
} |
Oops, something went wrong.