Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
needs: [prepare]
if: needs.prepare.outputs.sha != '' && needs.prepare.outputs.workspaces != ''
permissions:
id-token: write
actions: read
contents: read
strategy:
Expand All @@ -64,8 +65,6 @@ jobs:
TF_IN_AUTOMATION: 1
TF_INPUT: 0
TF_WORKSPACE: ${{ matrix.workspace }}
AWS_ACCESS_KEY_ID: ${{ secrets.RW_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RW_AWS_SECRET_ACCESS_KEY }}
GITHUB_APP_ID: ${{ secrets.RW_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', matrix.workspace)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RW_GITHUB_APP_PEM_FILE }}
Expand All @@ -82,6 +81,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-rw
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init
- name: Download reviewed terraform plan
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
needs: [prepare]
if: needs.prepare.outputs.workspaces != ''
permissions:
id-token: write
contents: write
strategy:
fail-fast: false
Expand All @@ -59,8 +60,6 @@ jobs:
TF_INPUT: 0
TF_LOCK: ${{ github.event.inputs.lock }}
TF_WORKSPACE_OPT: ${{ matrix.workspace }}
AWS_ACCESS_KEY_ID: ${{ secrets.RW_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RW_AWS_SECRET_ACCESS_KEY }}
GITHUB_APP_ID: ${{ secrets.RW_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', matrix.workspace)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RW_GITHUB_APP_PEM_FILE }}
Expand All @@ -76,6 +75,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-rw
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init -upgrade
working-directory: terraform
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
needs: [prepare]
if: needs.prepare.outputs.skip-fix == 'false'
permissions:
id-token: write
contents: read
pull-requests: write
strategy:
Expand All @@ -75,8 +76,6 @@ jobs:
TF_IN_AUTOMATION: 1
TF_INPUT: 0
TF_WORKSPACE: ${{ matrix.workspace }}
AWS_ACCESS_KEY_ID: ${{ secrets.RO_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RO_AWS_SECRET_ACCESS_KEY }}
GITHUB_APP_ID: ${{ secrets.RO_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RO_GITHUB_APP_INSTALLATION_ID_{0}', matrix.workspace)] || secrets.RO_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RO_GITHUB_APP_PEM_FILE }}
Expand All @@ -98,6 +97,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-ro
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init
working-directory: terraform
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
plan:
needs: [prepare]
permissions:
id-token: write
contents: read
pull-requests: read
strategy:
Expand All @@ -63,8 +64,6 @@ jobs:
TF_IN_AUTOMATION: 1
TF_INPUT: 0
TF_WORKSPACE: ${{ matrix.workspace }}
AWS_ACCESS_KEY_ID: ${{ secrets.RO_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RO_AWS_SECRET_ACCESS_KEY }}
GITHUB_APP_ID: ${{ secrets.RO_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RO_GITHUB_APP_INSTALLATION_ID_{0}', matrix.workspace)] || secrets.RO_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RO_GITHUB_APP_PEM_FILE }}
Expand All @@ -85,6 +84,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-ro
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init
working-directory: terraform
Expand All @@ -104,14 +109,12 @@ jobs:
needs: [prepare, plan]
if: github.event_name == 'pull_request_target'
permissions:
id-token: write
contents: read
pull-requests: write
name: Comment
runs-on: ubuntu-latest
environment: read
env:
AWS_ACCESS_KEY_ID: ${{ secrets.RO_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RO_AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -128,6 +131,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-ro
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init
working-directory: terraform
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
needs: [prepare]
if: needs.prepare.outputs.workspaces != ''
permissions:
id-token: write
contents: write
strategy:
fail-fast: false
Expand All @@ -57,8 +58,6 @@ jobs:
TF_INPUT: 0
TF_LOCK: ${{ github.event.inputs.lock }}
TF_WORKSPACE_OPT: ${{ matrix.workspace }}
AWS_ACCESS_KEY_ID: ${{ secrets.RW_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.RW_AWS_SECRET_ACCESS_KEY }}
GITHUB_APP_ID: ${{ secrets.RW_GITHUB_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ secrets[format('RW_GITHUB_APP_INSTALLATION_ID_{0}', matrix.workspace)] || secrets.RW_GITHUB_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.RW_GITHUB_APP_PEM_FILE }}
Expand All @@ -74,6 +73,12 @@ jobs:
with:
terraform_version: 1.12.0
terraform_wrapper: false
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@45666896f5d8e0f10ae255413f3a4cdd03bdc8f5 # v6.3.1
with:
role-to-assume: arn:aws:iam::941641221830:role/filoz-github-mgmt-filozone-rw
aws-region: us-east-1
allowed-account-ids: "941641221830"
- name: Initialize terraform
run: terraform init -upgrade
working-directory: terraform
Expand Down
84 changes: 5 additions & 79 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,81 +11,12 @@

## AWS

*NOTE*: Setting up AWS can be automated with [terraform](../terraform/bootstrap/aws.tf). If you choose to create AWS with terraform, remember that you'll still need to retrieve `AWS_ACCESS_KEY_ID`s and `AWS_SECRET_ACCESS_KEY`s manually.
FilOzone uses a versioned S3 bucket for Terraform state and [S3 lock files](https://developer.hashicorp.com/terraform/language/backend/s3#enabling-s3-state-locking). GitHub Actions uses [OIDC](https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-aws) to assume one of two IAM roles.

- [ ] [Create a S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/creating-bucket.html) - *this is where Terraform states for the organizations will be stored*
- [ ] [Create a DynamoDB table](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/getting-started-step-1.html) using `LockID` of type `String` as the partition key - *this is where Terraform state locks will be stored*
- [ ] [Create 2 IAM policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html) - *they are going to be attached to the users that GitHub Management is going to use to interact with AWS*
<details><summary>Read-only</summary>

```
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::$S3_BUCKET_NAME"
},
{
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::$S3_BUCKET_NAME/*"
},
{
"Action": [
"dynamodb:GetItem"
],
"Effect": "Allow",
"Resource": "arn:aws:dynamodb:*:*:table/$DYNAMO_DB_TABLE_NAME"
}
]
}
```
</details>
<details><summary>Read & Write</summary>

```
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::$S3_BUCKET_NAME"
},
{
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:DeleteObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::$S3_BUCKET_NAME/*"
},
{
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem"
],
"Effect": "Allow",
"Resource": "arn:aws:dynamodb:*:*:table/$DYNAMO_DB_TABLE_NAME"
}
]
}
```
</details>
- [ ] [Create 2 IAM Users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html) and save their `AWS_ACCESS_KEY_ID`s and `AWS_SECRET_ACCESS_KEY`s - *they are going to be used by GitHub Management to interact with AWS*
- [ ] one with read-only policy attached
- [ ] one with read & write policy attached
- [ ] Modify [terraform/terraform_override.tf](terraform/terraform_override.tf) to reflect your AWS setup
- [ ] Use the [bootstrap Terraform configuration](../terraform/bootstrap/aws.tf) to manage the bucket and roles in the FilOz AWS account. The account already has the GitHub Actions OIDC provider.
- [ ] Keep the bootstrap Terraform state in secure storage and use that state for subsequent changes to the bucket and roles.
- [ ] If you change the backend, keep [terraform/terraform_override.tf](../terraform/terraform_override.tf), the IAM policies, and the workflow role ARNs in sync.
- [ ] Restrict the GitHub Actions `write` environment to `master`. The read-only role trusts the `read` environment, and the read-write role trusts the `write` environment.

## GitHub App

Expand Down Expand Up @@ -127,11 +58,6 @@
- [ ] Go to `https://github.com/organizations/$GITHUB_ORGANIZATION_NAME/settings/apps/$GITHUB_APP_NAME`, click `Generate a private key` and copy the contents of the downloaded PEM file
- [ ] `RO_GITHUB_APP_PEM_FILE`
- [ ] `RW_GITHUB_APP_PEM_FILE`
- [ ] Use the values generated during [AWS](#aws) setup
- [ ] `RO_AWS_ACCESS_KEY_ID`
- [ ] `RW_AWS_ACCESS_KEY_ID`
- [ ] `RO_AWS_SECRET_ACCESS_KEY`
- [ ] `RW_AWS_SECRET_ACCESS_KEY`

## GitHub Management Repository Setup

Expand Down
32 changes: 18 additions & 14 deletions terraform/bootstrap/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading