Skip to content

Commit 01be59c

Browse files
Merge pull request #1 from sourcefuse/feature/redshift-module
Terraform configuration for Redshift module
2 parents 3be0c7b + e4ed57e commit 01be59c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3113
-250
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/snyk.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/terraform-test.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
name: Terratest
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
types: [opened]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: 'Pull Request Number'
10+
required: true
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
statuses: write # Required for setting commit status
16+
17+
jobs:
18+
terratest:
19+
runs-on: ubuntu-latest
20+
name: Terratest Checks
21+
22+
env:
23+
PR_NUMBER: >-
24+
${{ github.event_name == 'workflow_dispatch' &&
25+
github.event.inputs.pr_number || github.event.pull_request.number }}
26+
steps:
27+
- name: Checkout PR code
28+
uses: actions/checkout@v4
29+
with:
30+
ref: refs/pull/${{ env.PR_NUMBER }}/head
31+
32+
- name: Configure AWS credentials via OIDC
33+
uses: aws-actions/configure-aws-credentials@v2
34+
with:
35+
role-to-assume: ${{ secrets.ARC_IAC_TERRATEST_ROLE }}
36+
aws-region: us-east-1
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v4
40+
with:
41+
go-version: '1.24'
42+
43+
- name: Set up Terraform
44+
uses: hashicorp/setup-terraform@v2
45+
with:
46+
terraform_version: 1.7.5
47+
terraform_wrapper: false
48+
49+
- name: Create test directory and download go from S3
50+
run: |
51+
mkdir -p terra-test
52+
aws s3 cp ${{ secrets.ARC_TERRATEST_GO_FILE }} terra-test/terra_test.go
53+
- name: Initialize Go module and install dependencies
54+
run: |
55+
cd terra-test
56+
ls
57+
go mod init terraform-test || true
58+
go get github.com/gruntwork-io/terratest/modules/terraform
59+
go get github.com/stretchr/testify/assert
60+
go mod tidy
61+
go test -v -timeout 100m
62+
- name: Report check status manually
63+
uses: actions/github-script@v7
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
script: |
67+
const pr_number = parseInt(process.env.PR_NUMBER);
68+
const pr = await github.rest.pulls.get({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
pull_number: pr_number,
72+
});
73+
const sha = pr.data.head.sha;
74+
await github.rest.repos.createCommitStatus({
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
sha: sha,
78+
state: 'success',
79+
context: 'terratest',
80+
description: 'Manual terratest completed successfully',
81+
target_url:
82+
`https://github.com/${context.repo.owner}/${context.repo.repo}` +
83+
`/actions/runs/${process.env.GITHUB_RUN_ID}`,
84+
});

.github/workflows/tflint.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ on: # yamllint disable-line rule:truthy
1212

1313
jobs:
1414
tflint:
15-
runs-on:
16-
- arc
15+
runs-on: ubuntu-latest
1716
name: tflint
1817
steps:
1918
- uses: actions/checkout@master

.github/workflows/trivy.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
# This is a basic workflow to help you get started with Actions
3+
4+
name: Trivy Scan
5+
6+
# Controls when the action will run. Triggers the workflow on pull request
7+
# events but only for the develop branch
8+
on: # yamllint disable-line rule:truthy
9+
push:
10+
branches:
11+
- "**" # matches every branch
12+
- "!main" # excludes main
13+
pull_request:
14+
branches:
15+
- main
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
# This workflow contains a single job called "trivy"
20+
trivy:
21+
# The type of runner that the job will run on
22+
runs-on: [self-hosted, linux, codebuild]
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27+
- uses: actions/checkout@v3
28+
29+
- name: Run Trivy vulnerability scanner in repo mode
30+
uses: aquasecurity/trivy-action@0.28.0
31+
with:
32+
scan-type: "fs"
33+
scan-ref: "${{ github.workspace }}"
34+
trivy-config: "${{ github.workspace }}/trivy.yaml"

.github/workflows/update-docs.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: Update-docs
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- main
7+
jobs:
8+
transfer-file:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
14+
- name: Pushes Readme file
15+
uses: dmnemec/copy_file_to_another_repo_action@main
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }}
19+
with:
20+
source_file: 'README.md'
21+
destination_repo: 'sourcefuse/arc-docs'
22+
destination_folder: 'docs/arc-iac-docs/modules/terraform-aws-arc-redshift'
23+
user_email: 'github-actions@github.com'
24+
user_name: ${{ github.actor }}
25+
commit_message: ${{ github.event.head_commit.message }}
26+
27+
- name: Pushes to another repository
28+
uses: cpina/github-action-push-to-another-repository@main
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }}
32+
with:
33+
source-directory: 'static'
34+
destination-github-username: 'sourcefuse'
35+
destination-repository-name: 'arc-docs'
36+
target-directory: 'docs/arc-iac-docs/modules/terraform-aws-arc-redshift/static'
37+
user-email: 'github-actions@github.com'
38+
user-name: ${{ github.actor }}
39+
target-branch: main
40+
commit-message: ${{ github.event.head_commit.message }}
41+
42+
- name: Pushes Module Usage Guide
43+
uses: dmnemec/copy_file_to_another_repo_action@main
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
API_TOKEN_GITHUB: ${{ secrets.ARC_DOCS_API_TOKEN_GITHUB }}
47+
with:
48+
source_file: 'docs/module-usage-guide/README.md'
49+
destination_repo: 'sourcefuse/arc-docs'
50+
destination_folder: 'docs/arc-iac-docs/modules/terraform-aws-arc-redshift/docs/module-usage-guide'
51+
user_email: 'github-actions@github.com'
52+
user_name: ${{ github.actor }}
53+
commit_message: ${{ github.event.head_commit.message }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.terraform
22
terraform.tfstate
33
*.tfstate*
4-
terraform.tfvars
54
*.backup
65
.idea
76
.external_momdules

.snyk

Lines changed: 0 additions & 2 deletions
This file was deleted.

.terraform.lock.hcl

Lines changed: 36 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)