Skip to content

Commit d784555

Browse files
authored
initial release
2 parents 9ae0369 + ff2f948 commit d784555

21 files changed

+478
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org/
2+
# GitHub respects this file to display their diffs / code reviews if in repo root
3+
# Seen in https://github.com/isaacs/github/issues/170 as a way to solve the 8 spaces tabs
4+
root = true
5+
6+
[*]
7+
max_line_length = 100 # NOTE: exception to Google Style, which is generally 80
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
# https://www.terraform.io/docs/configuration/style.html
13+
[*.tf]
14+
indent_style = space
15+
indent_size = 2

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> Description here
2+
3+
### Fixes
4+
> paste links to issues/tasks in project management
5+
- []()
6+
7+
### Features
8+
> paste links to issues/tasks in project management
9+
- []()
10+
11+
### Change implications
12+
13+
- dependencies added/changed? **yes (explain) / no**
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Terraform CI - Integration
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- 'rc-*'
9+
10+
11+
jobs:
12+
validate:
13+
name: 'Terraform integration'
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: 'read'
17+
id-token: 'write'
18+
env:
19+
TERRAFORM_VERSION: 1.3.7
20+
CI_SA_EMAIL: gh-actions-tf-aws-export@worklytics-corp.iam.gserviceaccount.com
21+
GCP_IDENTITY_POOL: 'projects/432357880585/locations/global/workloadIdentityPools/github-actions/providers/github'
22+
EXAMPLE_TENANT_SA_EMAIL: tf-aws-export-tenant@worklytics-ci.iam.gserviceaccount.com
23+
EXAMPLE_TENANT_SA_ID: '104184075060961394622'
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
AWS_REGION: 'us-west-2'
26+
steps:
27+
- name: Get timestamp
28+
id: timestamp
29+
run: |
30+
echo "timestamp=$(date +%Y%m%d'T'%H%M%S)" >> $GITHUB_ENV
31+
32+
- name: Check out code
33+
uses: actions/checkout@v3
34+
35+
- name: 'setup Terraform'
36+
uses: hashicorp/setup-terraform@v2
37+
with:
38+
terraform_version: ${{ env.TERRAFORM_VERSION }}
39+
terraform_wrapper: false
40+
41+
- id: 'auth-gcp'
42+
name: 'Authenticate to Google Cloud'
43+
uses: google-github-actions/auth@v1
44+
with:
45+
workload_identity_provider: ${{ env.GCP_IDENTITY_POOL }}
46+
service_account: ${{ env.CI_SA_EMAIL }}
47+
48+
# see : https://github.com/aws-actions/configure-aws-credentials
49+
- name: configure aws credentials
50+
uses: aws-actions/configure-aws-credentials@v1
51+
with:
52+
role-to-assume: arn:aws:iam::626567183302:role/gh_action_ci_agent
53+
role-session-name: github_ci
54+
aws-region: ${{ env.AWS_REGION }}
55+
56+
- name: 'Terraform - integration test examples/basic apply'
57+
id: terraform_apply
58+
working-directory: examples/basic
59+
run: |
60+
terraform init
61+
terraform apply -var="resource_name_prefix=tf_aws_w8s_export_ci_${{ env.timestamp}}" -var="worklytics_tenant_id=${{ env.EXAMPLE_TENANT_SA_ID }}" -auto-approve
62+
echo "worklytics_export_bucket_id=$(terraform output -raw worklytics_export_bucket_id)" >> $GITHUB_OUTPUT
63+
echo "worklytics_tenant_aws_role_arn=$(terraform output -raw worklytics_tenant_aws_role_arn)" >> $GITHUB_OUTPUT
64+
65+
- name: 'Terraform - integration test examples/basic s3 write'
66+
run: |
67+
./test/rsync.sh ${{ env.EXAMPLE_TENANT_SA_EMAIL }} ${{ steps.terraform_apply.outputs.worklytics_export_bucket_id }} ${{ steps.terraform_apply.outputs.worklytics_tenant_aws_role_arn }}
68+
69+
- name: 'Terraform - integration test examples/basic terraform destroy'
70+
if: always() # try to force this to ALWAYS happen, no matter if previous stuff failed
71+
working-directory: examples/basic
72+
run: |
73+
aws s3 rm s3://${{ steps.terraform_apply.outputs.worklytics_export_bucket_id }} --recursive
74+
terraform destroy -auto-approve -var="worklytics_tenant_id=${{ env.EXAMPLE_TENANT_SA_ID }}"

.github/workflows/terraform_lint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Terraform CI - Lint
2+
3+
on:
4+
[push]
5+
6+
jobs:
7+
lint:
8+
name: 'Terraform lint'
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: 'read'
12+
id-token: 'write'
13+
env:
14+
TERRAFORM_VERSION: 1.3.7
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
19+
- name: 'setup Terraform'
20+
uses: hashicorp/setup-terraform@v2
21+
with:
22+
terraform_version: ${{ env.TERRAFORM_VERSION }}
23+
24+
- name: 'lint Terraform code'
25+
# see https://www.terraform.io/cli/commands/fmt
26+
run:
27+
terraform fmt -check -recursive -diff .
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Terraform CI - validate
2+
3+
on:
4+
[push]
5+
6+
jobs:
7+
validate:
8+
name: 'Terraform validate'
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: 'read'
12+
id-token: 'write'
13+
env:
14+
TERRAFORM_VERSION: 1.3.7
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v3
18+
19+
- name: 'setup Terraform'
20+
uses: hashicorp/setup-terraform@v2
21+
with:
22+
terraform_version: ${{ env.TERRAFORM_VERSION }}
23+
24+
- name: 'Terraform - validate examples/basic'
25+
working-directory: examples/basic
26+
run: |
27+
terraform init
28+
terraform validate

.idea/.gitignore

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

.idea/misc.xml

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

.idea/modules.xml

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

.idea/terraform-aws-worklytics-export.iml

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

.idea/vcs.xml

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

0 commit comments

Comments
 (0)