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

fix(@aws-cdk/aws-elasticloadbalancingv2)/logAccessLogs provides open permissions on log bucket for alb #2929

Merged
merged 4 commits into from
Jun 21, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import cloudwatch = require('@aws-cdk/aws-cloudwatch');
import ec2 = require('@aws-cdk/aws-ec2');
import iam = require('@aws-cdk/aws-iam');
import s3 = require('@aws-cdk/aws-s3');
import cdk = require('@aws-cdk/cdk');
import { Construct, Lazy, Resource, Stack, Token } from '@aws-cdk/cdk';
import { BaseLoadBalancer, BaseLoadBalancerProps, ILoadBalancerV2 } from '../shared/base-load-balancer';
import { IpAddressType } from '../shared/enums';
Expand Down Expand Up @@ -97,7 +98,7 @@ export class ApplicationLoadBalancer extends BaseLoadBalancer implements IApplic
}

prefix = prefix || '';
bucket.grantPut(new iam.AccountPrincipal(account), prefix + '*');
bucket.grantPut(new iam.AccountPrincipal(account), cdk.Fn.sub((prefix ? prefix + "/" : "") + 'AWSLogs/' + "${AWS::AccountId}" + '/*'));
made2591 marked this conversation as resolved.
Show resolved Hide resolved

// make sure the bucket's policy is created before the ALB (see https://github.com/awslabs/aws-cdk/issues/1633)
this.node.addDependency(bucket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export = {
Action: [ "s3:PutObject*", "s3:Abort*" ],
Effect: 'Allow',
Principal: { AWS: { "Fn::Join": [ "", [ "arn:", { Ref: "AWS::Partition" }, ":iam::127311923021:root" ] ] } },
Resource: { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "AccessLoggingBucketA6D88F29", "Arn" ] }, "/*" ] ] }
Resource: { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "AccessLoggingBucketA6D88F29", "Arn" ] }, "/",
{ "Fn::Sub": "AWSLogs/${AWS::AccountId}/*" } ] ] }
}
]
}
Expand Down Expand Up @@ -198,7 +199,8 @@ export = {
Action: [ "s3:PutObject*", "s3:Abort*" ],
Effect: 'Allow',
Principal: { AWS: { "Fn::Join": [ "", [ "arn:", { Ref: "AWS::Partition" }, ":iam::127311923021:root" ] ] } },
Resource: { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "AccessLoggingBucketA6D88F29", "Arn" ] }, "/prefix-of-access-logs*" ] ] }
Resource: { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "AccessLoggingBucketA6D88F29", "Arn" ] }, "/",
{ "Fn::Sub": "prefix-of-access-logs/AWSLogs/${AWS::AccountId}/*" } ] ] }
}
]
}
Expand Down