Skip to content
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

Attach a Permissions Boundary to Workload Discovery Roles #448

Open
wants to merge 5 commits into
base: main
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
16 changes: 16 additions & 0 deletions source/cfn/templates/account-import-templates-resolvers.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Parameters:
PerspectiveAppSyncApiId:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

AccountImportTemplatesApiLambdaFunctionRole:
Expand All @@ -30,6 +42,8 @@ Resources:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

AccountImportTemplatesApiFunction:
Metadata:
Expand Down Expand Up @@ -77,6 +91,8 @@ Resources:
Action:
- lambda:InvokeFunction
Resource: !GetAtt AccountImportTemplatesApiFunction.Arn
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

AccountImportTemplatesApiLambdaDataSource:
Type: AWS::AppSync::DataSource
Expand Down
16 changes: 15 additions & 1 deletion source/cfn/templates/appsync-api.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ Parameters:
CognitoUserPoolId:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

PerspectiveAppSyncLoggingRole:
Expand Down Expand Up @@ -48,6 +60,8 @@ Resources:
Action:
- logs:PutLogEvents
Resource: !Sub 'arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:*'
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

PerspectiveAppSyncApi:
Type: AWS::AppSync::GraphQLApi
Expand Down Expand Up @@ -76,4 +90,4 @@ Outputs:
AppSyncApiArn:
Value: !GetAtt PerspectiveAppSyncApi.Arn
AppSyncApiUrl:
Value: !GetAtt PerspectiveAppSyncApi.GraphQLUrl
Value: !GetAtt PerspectiveAppSyncApi.GraphQLUrl
16 changes: 16 additions & 0 deletions source/cfn/templates/athena-glue-crawler.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Parameters:
DeploymentBucketKey:
Type: String
Description: "The key to the deployment code for Perspective"
AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String
PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:
AWSCURDatabase:
Expand Down Expand Up @@ -70,6 +80,8 @@ Resources:
- 's3:GetObject'
- 's3:PutObject'
Resource: !Sub 'arn:${AWS::Partition}:s3:::${CostAndUsageBucket}/${CURCrawlerKey}/*'
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

AWSCURCrawlerLambdaExecutor:
Metadata:
Expand Down Expand Up @@ -113,6 +125,8 @@ Resources:
Action:
- 'glue:StartCrawler'
Resource: '*'
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

AWSCURCrawler:
Type: 'AWS::Glue::Crawler'
Expand Down Expand Up @@ -202,6 +216,8 @@ Resources:
Action:
- 's3:PutBucketNotification'
Resource: !Sub 'arn:${AWS::Partition}:s3:::${CostAndUsageBucket}'
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

AWSS3CURNotification:
Metadata:
Expand Down
14 changes: 13 additions & 1 deletion source/cfn/templates/buckets.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ Parameters:
S3CleanupBucket:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
CreateConfigBucket: !Equals
- Ref: CreateConfigBucket
- "true"
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:
# The custom resource disables access logging because otherwise logs will be
Expand Down Expand Up @@ -412,6 +422,8 @@ Resources:
- Ref: "AWS::NoValue"
Runtime: python3.8
Timeout: 60
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

CleanupAccessLogsBucket:
Type: "Custom::S3BucketCleanup"
Expand Down Expand Up @@ -501,4 +513,4 @@ Outputs:
Value: !Ref WebUIBucket

WebUIBucketRegionalDomainName:
Value: !GetAtt WebUIBucket.RegionalDomainName
Value: !GetAtt WebUIBucket.RegionalDomainName
18 changes: 17 additions & 1 deletion source/cfn/templates/codebuild.template
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ Parameters:
SolutionVersion:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

CodeBuildRole:
Expand Down Expand Up @@ -91,6 +103,8 @@ Resources:
- s3:PutObject
Resource:
- !Sub "arn:aws:s3:::${WebUIBucket}/*"
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

CodeBuildProject:
Type: AWS::CodeBuild::Project
Expand Down Expand Up @@ -182,4 +196,6 @@ Resources:
Resource: !GetAtt CodeBuildProject.Arn
Runtime: python3.8
ReservedConcurrentExecutions: 1
Timeout: 900
Timeout: 900
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]
16 changes: 15 additions & 1 deletion source/cfn/templates/cognito.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ Parameters:
WebUiUrl:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

CognitoAuthRole:
Expand Down Expand Up @@ -70,6 +82,8 @@ Resources:
- Action: s3:ListBucket
Resource: !Sub "arn:aws:s3:::${AmplifyStorageBucket}"
Effect: "Allow"
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

IdentityPoolRoleMap:
Type: AWS::Cognito::IdentityPoolRoleAttachment
Expand Down Expand Up @@ -144,4 +158,4 @@ Outputs:
UserPoolARN:
Value: !GetAtt WDCognitoUserPool.Arn
WebClientId:
Value: !Ref UserPoolClient
Value: !Ref UserPoolClient
12 changes: 12 additions & 0 deletions source/cfn/templates/config-aggregator.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ Parameters:
ConfigBucket:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
SetUpConfig: !Equals [!Ref ExistingConfigInstallation, 'No']
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

Expand Down Expand Up @@ -78,6 +88,8 @@ Resources:
Condition:
StringEquals:
s3:x-amz-acl: bucket-owner-full-control
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

Outputs:

Expand Down
16 changes: 16 additions & 0 deletions source/cfn/templates/cost-resolvers.template
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ Parameters:
CustomUserAgent:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

PerspectiveCostLambdaRole:
Expand Down Expand Up @@ -111,6 +123,8 @@ Resources:
- !Sub arn:aws:glue:${AWS::Region}:${AWS::AccountId}:catalog
- !Sub arn:aws:glue:${AWS::Region}:${AWS::AccountId}:database/${AthenaDatabaseName}
- !Sub arn:aws:glue:${AWS::Region}:${AWS::AccountId}:table/${AthenaDatabaseName}/${AthenaTableName}
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

PerspectiveCostFunction:
Metadata:
Expand Down Expand Up @@ -161,6 +175,8 @@ Resources:
Action:
- lambda:InvokeFunction
Resource: !GetAtt PerspectiveCostFunction.Arn
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

PerspectiveAppSyncCostLambdaDataSource:
Type: AWS::AppSync::DataSource
Expand Down
18 changes: 18 additions & 0 deletions source/cfn/templates/discovery-crawler.template
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ Parameters:
Type: String
Default: 'AwsSolution/SO0075/1.1.0'

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:
PerspectiveContainerRepo:
Type: AWS::ECR::Repository
Expand Down Expand Up @@ -164,6 +176,8 @@ Resources:
Environment:
Variables:
CustomUserAgent: !Ref CustomUserAgent
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

CleanupECRRepository:
Type: Custom::Setup
Expand Down Expand Up @@ -197,6 +211,8 @@ Resources:
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceEventsRole
- arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

PerspectiveDiscoveryTaskRole:
Type: AWS::IAM::Role
Expand Down Expand Up @@ -260,6 +276,8 @@ Resources:
Action:
- appsync:GraphQL
Resource: !Sub ${AppSyncArn}/*
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

TaskDefinition:
Type: AWS::ECS::TaskDefinition
Expand Down
18 changes: 18 additions & 0 deletions source/cfn/templates/draw-io-resolvers.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ Parameters:
PerspectiveAppSyncApiId:
Type: String

AttachPermissionsBoundary:
Description: Attach Permissions Boundary
Type: String

PermissionsBoundaryName:
Description: Name of optional Permissions Boundary
Type: String

Conditions:
AttachPermissionsBoundary:
!Equals [!Ref AttachPermissionsBoundary, 'Yes']

Resources:

DrawIoLambdaFunctionRole:
Expand All @@ -30,6 +42,8 @@ Resources:
Service:
- lambda.amazonaws.com
Action: sts:AssumeRole
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

DrawIoFunction:
Type: AWS::Serverless::Function
Expand All @@ -48,6 +62,8 @@ Resources:
Timeout: 5
MemorySize: 256
ReservedConcurrentExecutions: 5
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

DrawIoInvokeRole:
Type: AWS::IAM::Role
Expand All @@ -70,6 +86,8 @@ Resources:
Action:
- lambda:InvokeFunction
Resource: !GetAtt DrawIoFunction.Arn
PermissionsBoundary:
!If [AttachPermissionsBoundary, !Ref PermissionsBoundaryName, !Ref "AWS::NoValue"]

DrawIoExportLambdaDataSource:
Type: AWS::AppSync::DataSource
Expand Down
Loading