When I create a new LogGroup and then call addToResourcePolicy with a valid policy, I get the error message
ARNs must start with "arn:" and have at least 6 components: *
Error message.
import { App, RemovalPolicy, Stack, StackProps } from 'aws-cdk-lib';
import { AnyPrincipal, PolicyStatement } from 'aws-cdk-lib/aws-iam';
import { LogGroup } from 'aws-cdk-lib/aws-logs';
import { Construct } from 'constructs';
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const r = new LogGroup(this, 'MyLogGroup', {
removalPolicy: RemovalPolicy.DESTROY,
});
// This fails, no matter what the policy.
r.addToResourcePolicy(new PolicyStatement({
actions: ['logs:CreateLogGroupLogStream', 'logs:DescribeLogStreams', 'logs:PutLogEvents'],
principals: [new AnyPrincipal()],
resources: ['*'],
}));
}
}
// for development, use account/region from cdk cli
const devEnv = {
account: process.env.CDK_DEFAULT_ACCOUNT,
region: process.env.CDK_DEFAULT_REGION,
};
const app = new App();
new MyStack(app, 'MyStack', { env: devEnv });
app.synth();
Describe the bug
When I create a new LogGroup and then call addToResourcePolicy with a valid policy, I get the error message
Expected Behavior
I should be able to
addToResourcePolicy.Current Behavior
Error message.
Reproduction Steps
https://github.com/ahammond/repro-loggroup-addtoresourcepolicy
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.103.1 (build 3bb19ac)
Framework Version
same
Node.js Version
20.5.1
OS
MacOS latest
Language
TypeScript
Language Version
4.9.5
Other information
No response