generated from NASA-PDS/template-repo-java
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cb6fb0
commit e40e275
Showing
5 changed files
with
174 additions
and
18 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,90 @@ | ||
name: 'Terraform-Workflow' | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
types: [opened, edited, reopened, ready_for_review, review_requested] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write # required to use OIDC authentication | ||
contents: read # required to checkout the code from the repo | ||
|
||
jobs: | ||
deploy: | ||
name: 'Terraform' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./terraform | ||
environment: NGAP DEV | ||
env: | ||
TF_LOG: INFO | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-region: "${{ secrets.AWS_REGION }}" | ||
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} | ||
role-session-name: PDS_GitHub_OIDC_TERRAFORM | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v2 | ||
|
||
- name: Terraform Fmt, Init & Validate | ||
id: fmt_init_validate | ||
env: | ||
AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME}} | ||
AWS_BUCKET_KEY_NAME: ${{ secrets.AWS_BUCKET_KEY_NAME}} | ||
run: | | ||
terraform fmt | ||
terraform init -backend-config="bucket=${AWS_BUCKET_NAME}" -backend-config="key=${AWS_BUCKET_KEY_NAME}" | ||
terraform validate -no-color | ||
- name: Terraform Plan | ||
id: plan | ||
if: github.event_name == 'pull_request' | ||
env: | ||
TF_VAR_aws_fg_vpc: "${{ secrets.AWS_FG_VPC }}" | ||
TF_VAR_aws_fg_security_groups: "${{ secrets.AWS_FG_SECURITY_GROUPS }}" | ||
TF_VAR_aws_fg_subnets: "${{ secrets.AWS_FG_SUBSETS }}" | ||
TF_VAR_aws_fg_cpu_units: 256 | ||
TF_VAR_aws_fg_ram_units: 512 | ||
TF_VAR_aws_fg_image: "${{ secrets.AWS_FG_IMAGE }}" | ||
TF_VAR_aws_lb_listener_arn: "${{ secrets.AWS_LB_LISTENER_ARN }}" | ||
TF_VAR_es_hosts: "${{ secrets.ES_HOSTS }}" | ||
TF_VAR_es_user_name: "${{ secrets.ES_USER_NAME }}" | ||
TF_VAR_http_header_forward_value: "search-en-delta/1" | ||
TF_VAR_node_name_abbr: "en" | ||
TF_VAR_venue: "delta" | ||
run: terraform plan -no-color | ||
continue-on-error: true | ||
|
||
- name: Terraform Plan Status | ||
id : plan_status | ||
if: steps.plan.outcome == 'failure' && github.event_name == 'pull_request' | ||
run: exit 1 | ||
|
||
- name: Terraform Apply | ||
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | ||
env: | ||
TF_VAR_aws_fg_vpc: "${{ secrets.AWS_FG_VPC }}" | ||
TF_VAR_aws_fg_security_groups: "${{ secrets.AWS_FG_SECURITY_GROUPS }}" | ||
TF_VAR_aws_fg_subnets: "${{ secrets.AWS_FG_SUBSETS }}" | ||
TF_VAR_aws_fg_cpu_units: 256 | ||
TF_VAR_aws_fg_ram_units: 512 | ||
TF_VAR_aws_fg_image: "${{ secrets.AWS_FG_IMAGE }}" | ||
TF_VAR_aws_lb_listener_arn: "${{ secrets.AWS_LB_LISTENER_ARN }}" | ||
TF_VAR_es_hosts: "${{ secrets.ES_HOSTS }}" | ||
TF_VAR_es_user_name: "${{ secrets.ES_USER_NAME }}" | ||
TF_VAR_http_header_forward_value: "search-en-delta/1" | ||
TF_VAR_node_name_abbr: "en" | ||
TF_VAR_venue: "delta" | ||
run: terraform apply -auto-approve |
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,21 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- id: check-yaml | ||
- id: check-json #checks json files for parseable syntax. | ||
- id: pretty-format-json #sets a standard for formatting json files. | ||
|
||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.81.0 | ||
hooks: | ||
- id: terraform_fmt #Rewrites all Terraform configuration files to a canonical format. | ||
- id: terraform_validate #Validates all Terraform configuration files. | ||
- id: terraform_tflint #Validates all Terraform configuration files with TFLint. | ||
# - id: terrascan #Detect compliance and security violations of Terraform templates. | ||
# - id: terraform_tfsec | ||
# - id: terraform_docs |
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