Skip to content

Commit

Permalink
Merge pull request #17 from hearchco/as/fix/github-scope
Browse files Browse the repository at this point in the history
fix(github): sub scope dispatch workflow
  • Loading branch information
aleksasiriski authored Apr 11, 2024
2 parents 9f4849a + dffb40b commit 42f2f77
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/deploy-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ jobs:
with:
role-to-assume: ${{ secrets.TF_SHARED_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
output-credentials: true

- name: Configure AWS Credentials File
run: |
mkdir -p ~/.aws
echo "[${{ steps.shared-tf-state.outputs.aws-account-id }}_TFStateLock]" >> ~/.aws/credentials
echo "aws_access_key_id=${{ steps.shared-tf-state.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=${{ steps.shared-tf-state.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=${{ steps.shared-tf-state.outputs.aws-session-token }}" >> ~/.aws/credentials
echo "aws_access_key_id=::add-mask::${{ steps.shared-tf-state.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=::add-mask::${{ steps.shared-tf-state.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=::add-mask::${{ steps.shared-tf-state.outputs.aws-session-token }}" >> ~/.aws/credentials
## AWS (prod)
- name: Configure AWS credentials for deployment (prod)
Expand All @@ -48,14 +49,15 @@ jobs:
with:
role-to-assume: ${{ secrets.BACKEND_PROD_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
output-credentials: true

- name: Configure AWS Credentials File (prod)
if: github.event.client_payload.environment == 'prod'
run: |
echo "[${{ steps.prod-deployment.outputs.aws-account-id }}_Admin]" >> ~/.aws/credentials
echo "aws_access_key_id=${{ steps.prod-deployment.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=${{ steps.prod-deployment.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=${{ steps.prod-deployment.outputs.aws-session-token }}" >> ~/.aws/credentials
echo "aws_access_key_id=::add-mask::${{ steps.prod-deployment.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=::add-mask::${{ steps.prod-deployment.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=::add-mask::${{ steps.prod-deployment.outputs.aws-session-token }}" >> ~/.aws/credentials
## AWS (dev)
- name: Configure AWS credentials for deployment (dev)
Expand All @@ -65,14 +67,15 @@ jobs:
with:
role-to-assume: ${{ secrets.BACKEND_DEV_ROLE }}
aws-region: ${{ secrets.AWS_REGION }}
output-credentials: true

- name: Configure AWS Credentials File (dev)
if: github.event.client_payload.environment == 'dev'
run: |
echo "[${{ steps.dev-deployment.outputs.aws-account-id }}_Admin]" >> ~/.aws/credentials
echo "aws_access_key_id=${{ steps.dev-deployment.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=${{ steps.dev-deployment.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=${{ steps.dev-deployment.outputs.aws-session-token }}" >> ~/.aws/credentials
echo "aws_access_key_id=::add-mask::${{ steps.dev-deployment.outputs.aws-access-key-id }}" >> ~/.aws/credentials
echo "aws_secret_access_key=::add-mask::${{ steps.dev-deployment.outputs.aws-secret-access-key }}" >> ~/.aws/credentials
echo "aws_session_token=::add-mask::${{ steps.dev-deployment.outputs.aws-session-token }}" >> ~/.aws/credentials
# Terraform
- name: Setup Terraform
Expand Down
4 changes: 1 addition & 3 deletions aws/dev/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module "github_oidc" {
module "github_backend_deploy" {
source = "../../modules/github/role"

name = "github-auth-backend-deploy"
repository = "hearchco/hearchco"

name = "github-auth-backend-deploy"
statements = [
{
actions = [
Expand Down
5 changes: 3 additions & 2 deletions aws/modules/github/role/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ variable "audience" {

// "<org_name>/<repo_name>"
variable "repository" {
type = string
type = string
default = "hearchco/infra"
}

// to allow all branches use "ref:refs/heads/*", to allow everything from the repo use "*"
variable "scope" {
type = string
default = "ref:refs/heads/main"
default = "*"
}

variable "statements" {
Expand Down
4 changes: 1 addition & 3 deletions aws/prod/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module "github_oidc" {
module "github_backend_deploy" {
source = "../../modules/github/role"

name = "github-auth-backend-deploy"
repository = "hearchco/hearchco"

name = "github-auth-backend-deploy"
statements = [
{
actions = [
Expand Down
4 changes: 1 addition & 3 deletions aws/shared/github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module "github_oidc" {
module "github_shared_tf_state" {
source = "../../modules/github/role"

name = "github-auth-shared-tf-state"
repository = "hearchco/hearchco"

name = "github-auth-shared-tf-state"
statements = [
{
actions = [
Expand Down

0 comments on commit 42f2f77

Please sign in to comment.