Skip to content

TS-2076 add conditional policy deployments #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
68 changes: 40 additions & 28 deletions ApiAuthVerifyToken/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ resources:
- ${self:provider.stage}
- "production"
#pre-production is self contained with its own authorizer
EnableCrossAccountAccess: !Not [!Equals [!${self:provider.stage}, "pre-production"]]
EnableCrossAccountAccess:
Fn::Not:
- Fn::Equals:
- ${self:provider.stage}
- "pre-production"

Resources:
AllowApisAccountAuthorizer:
Expand Down Expand Up @@ -157,7 +161,7 @@ resources:
- "lambda:InvokeFunction"
Resource: "*"
- PolicyName: assumeRoleForGettingCredentialsApiAccount
# ProductionApis, StagingApis and housing-pre-production
# ProductionApis, StagingApis and Housing-Pre-Production
PolicyDocument:
Version: "2012-10-17"
Statement:
Expand All @@ -170,32 +174,36 @@ resources:
- - "arn:aws:iam::"
- Ref: "AWS::AccountId"
- ":role/LBH_Api_Gateway_Allow_GET"
- PolicyName: assumeRoleForGettingCredentialsHousingAccount
- !If
- EnableCrossAccountAccess
- PolicyName: assumeRoleForGettingCredentialsHousingAccount
# Housing-Production or Housing-Staging
Condition: EnableCrossAccountAccess
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Resource:
Fn::Join:
- ""
- - "arn:aws:iam::"
- ${self:custom.housingAccountIds.${self:provider.stage}}
- ":role/LBH_Api_Gateway_Allow_GET"
- PolicyName: assumeRoleForGettingCredentialsDESAccount
# Document-Evidence-Store Staging and Production
Condition: EnableCrossAccountAccess
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Resource:
Fn::Sub: arn:aws:iam::${self:custom.desAccountIds.${self:provider.stage}}:role/LBH_Api_Gateway_Allow_GET
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Resource:
Fn::Join:
- ""
- - "arn:aws:iam::"
- ${self:custom.housingAccountIds.${self:provider.stage}}
- ":role/LBH_Api_Gateway_Allow_GET"
- !Ref AWS::NoValue
- !If
- EnableCrossAccountAccess
- PolicyName: assumeRoleForGettingCredentialsDESAccount
# Document-Evidence-Store Staging and Production
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "sts:AssumeRole"
Resource:
Fn::Sub: arn:aws:iam::${self:custom.desAccountIds.${self:provider.stage}}:role/LBH_Api_Gateway_Allow_GET
- !Ref AWS::NoValue
- PolicyName: getAPIGatewayAPIName
PolicyDocument:
Version: "2012-10-17"
Expand Down Expand Up @@ -224,10 +232,13 @@ custom:
development: "364864573329"
staging: "087586271961"
production: "282997303675"
pre-production: "578479666894"
desAccountIds:
development: "549011513230"
staging: "549011513230"
production: "658402009206"
#dummy account number to ensure all variables can be resolved for all stages. Won't be actually used for any resources
pre-production: "111111111111"
disasterRecoveryAccountIds:
production: "851725205572"
vpc:
Expand All @@ -250,7 +261,8 @@ custom:
- subnet-01d3657f97a243261
- subnet-0b7b8fea07efabf34
pre-production:
securityGroupIds:
- sg-08dd301b41ec262e2
subnetIds:
- subnet-08aa35159a8706faa
- subnet-0b848c5b14f841dfb

2 changes: 1 addition & 1 deletion terraform/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "aws_dynamodb_table" "api_authenticator_dynamodb_table" {
project_name = "api-authenticator"
Application = "API Authenticator"
TeamEmail = "[email protected]"
BackupPolicy = "Dev"
BackupPolicy = "Prod"
Confidentiality = "Internal"
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "aws_dynamodb_table" "api_authenticator_dynamodb_table" {
project_name = "api-authenticator"
Application = "API Authenticator"
TeamEmail = "[email protected]"
BackupPolicy = "Stg"
BackupPolicy = "Prod"
Confidentiality = "Internal"
}

Expand Down