-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(logs): Log Group ARN has extra :*
#18253
Comments
I believe that this is intentional, since the arn comes directly from CloudFormation. Here's where the arn is set aws-cdk/packages/@aws-cdk/aws-logs/lib/log-group.ts Lines 403 to 417 in bfbdf64
I'm not sure what we would want to do here, since I'm not sure why CloudFormation includes this in the arn in the first place. @comcalvi what do you think? |
This is likely a bug in WAFv2. The CFN property that causes the issue,
In the console, that log group has the Another workaround is to use |
Workaround example in CDKv2
|
Someone managed to solve it? i can't use the provided ARN, i get this error |
import * as cdk from "@aws-cdk/core";
import * as waf from "@aws-cdk/aws-wafv2";
import * as cwLogs from "@aws-cdk/aws-logs";
...
const loggingGroup = new cwLogs.LogGroup(this, "LogGroup", {
// waf log group names must start with "aws-waf-logs-" or the stack will not deploy
logGroupName: "aws-waf-logs-myname",
retention: cwLogs.RetentionDays.ONE_MONTH,
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
new waf.CfnLoggingConfiguration(this, "LoggingConfiguration", {
// the arn that comes back natively from the LogGroup has ":*" appended on the end of it, including it on the destination will cause a deploy time error
logDestinationConfigs: [cdk.Fn.select(0, cdk.Fn.split(":*", loggingGroup.logGroupArn))],
resourceArn: this.webAcl.attrArn,
}); |
It seems that workaround doesn't work anymore.
Old stacks deployed before are updated without issues.
Can anyone confirm this issue even with workraround applied? |
We faced the same issue. Started suddenly getting
@lacteolus Did you find a solution for this? Thanks ! |
I just had the exact same issue. We were tyring to deploy stack with StateMachine configured with logging but it kept failing with
For CloudFormation stacks we are using L1 and L2 AWS CDK Constructs. We create an L1 LogGroup with CfnLogGroup construct. But we are using L2 StateMachine construct. Since L2 StateMachine construct only accepts We were using it like this:
Turns out, CfnLogGroup.attrArn returns ARN with
But the problem arises when
Which is in my opinion wrong, in the AWS console, the LogGroup ARN has the So when we made this call:
The Log Group ARN passed to StateMachine had I have fixed this issue by constructing L2 LogGroup construct from name:
But in my opinion |
@aidbal the behavior you're describing is working as intended. In the past, |
Hi @comcalvi, thanks for linking me the PR. I agree that there was a need to patch the bug which caused incorrect permissions. I think that your patch created another bug (the one I mentioned) unintentionally. And it's not about mixing L1 and L2, I can easily break your bug fix by only using L2 constructs (explained at the end) Why the bug fix is not completeHere you guys check if the arn has However, you don't put into the consideration that the ARN might be a token and so your regex might not find anything. I think the better approach there would have been to check if it's a token. If so, don't append any I think this makes the most sense as the LogGroupArn in AWS Console shows up with Meaning the user expects the ARN of the LogGroup to always be the one with Breaking your bug fix with L2 onlyIf you don't fix this bug and say that it only affects it when L1 and L2 are mixed together, I can easily create L2 Log group and get the ARN from that: const logGroupL2 = new LogGroup(this, "LogGroupL2")
const stateMachine = new StateMachine(this, "StateMachine", {
...
logs: {
destination: LogGroup.fromLogGroupArn(this, "LogGroupFromArn", logGroupL2.logGroupArn)
level: LogLevel.ALL
}
}) This results in the following CloudFormation code: "CloudWatchLogsLogGroup": {
"LogGroupArn": {
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"LogGroupL255E4F451",
"Arn"
]
},
":*"
]
]
}
} No L1 construct being mixed in, but still breaks your bug fix. |
What is the status of this bug? Is it still not possible to create an ACL via CDK with a cloudwatch log group? |
Yes, it's a different issue.
|
Did anyone find a solution to this? I get the same error:
No matter how I format the ARN. I have tried the mentioned workaround In my case the log group already exists, and have tried specifying the ARN 6 different ways, hardcoding it to get around the L1 & L2 constructs "not playing nice" - as mentioned in a post above. Example CDK snippet with the different ARNs attempted:
I have also tried another approach of using an s3 bucket as the logDestinationConfigs, for this approach I use a Kinesis stream for log delivery to s3, the stream has the managed policy AWSWAFFullAccess on it role, and the log destination is configured as follows: Not sure I understand what the problem is here - has anyone got a workaround that still works? Update: I have resolved this. |
Probably related to the Log Group name requirement? https://docs.aws.amazon.com/waf/latest/developerguide/logging-cw-logs.html#logging-cw-logs-naming |
This is so stupid. The error is the Log group Name must start with F AWS, F Microsoft |
Just bumped this issue to p1 and self-assigned. I will be looking into this issue and escalate to the team when necessary. |
I am able to export class DummyStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const acl = new wafv2.CfnWebACL(this, "ACL", {
scope: "REGIONAL",
defaultAction: {
allow: {},
},
visibilityConfig: {
sampledRequestsEnabled: true,
cloudWatchMetricsEnabled: true,
metricName: "SampleACLMetric",
},
rules: [
{
name: "RuleWithAWSManagedRules",
priority: 0,
overrideAction: {
none: {},
},
statement: {
managedRuleGroupStatement: {
vendorName: "AWS",
name: "AWSManagedRulesCommonRuleSet",
excludedRules: [],
},
},
visibilityConfig: {
sampledRequestsEnabled: true,
cloudWatchMetricsEnabled: true,
metricName: "SampleAWSManagedRulesMetric",
},
},
],
});
const aclLogGroup = new logs.LogGroup(this, "ACLLogs", {
// WAFv2 Log Groups must begin with `aws-waf-logs`. Including the ACL's
// ID hopefully prevents name conflicts.
logGroupName: `aws-waf-logs-${acl.attrId}`,
});
const logConfig = new wafv2.CfnLoggingConfiguration(this, "WebAclLogging", {
logDestinationConfigs: [aclLogGroup.logGroupArn],
resourceArn: acl.attrArn,
});
}
} The I assume this issue does not exist anymore. Please comment if does. % npx cdk --version |
Probably CDK might be already handling LogGroup's ARN with extra |
hi @pahud, I confirm is also working for me
PS: I had a typo before in the WAFv2 Log Group name, I am mentioning this for others as well even if it was already mentioned in this thread at least a few times, please take note on: |
As this issue doesn't seem to existing anymore. I am closing it now. |
|
Same here, I bumped into this issue today using L2 construct to create a log group for my cognito service Besides, I also found a open issue on Re: Post, CloudFormation regex validation error in Cognito::LogDeliveryConfiguration. Unluckily, by the time I am writing, this issue still exists though |
What is the problem?
The
logGroupArn
attribute for aLogGroup
L2 construct has an extra:*
at the end of the ARN. While this matches the behavior of CloudFormation'sArn
attribute for anAWS::Logs::LogGroup
, it does not match the documented structure for a Log Group. This breaks integration with other services, such as the creation of anAWS::WAFv2::LoggingConfiguration
, which requires the ARN of the Log Group without:*
.Reproduction Steps
Build the following constructs within a
Stack
. (Sorry for the length; building a Web ACL is noisy)What did you expect to happen?
The
AWS::WAFv2::LoggingConfiguration
resource should create successfully, referencing thelogGroupArn
attribute directly.The
LogGroup
construct should provide the ARN in the format specified by the documentation, includingWhat actually happened?
The
AWS::WAFv2::LoggingConfiguration
resource failed to create with the error:The
LogGroup.logGroupArn
had an:*
that was not documented as part of the ARN according to most documentation for the ARN of a Log Group.CDK CLI Version
2.3.0 (build beaa5b2)
Framework Version
No response
Node.js Version
v14.18.2
OS
Linux
Language
Typescript
Language Version
No response
Other information
It may be more viable to fix this in other L2 constructs that need a log group than it is to fix it in the
LogGroup
construct itself at this point (and it doesn't seem that L2 constructs for the Web ACL logging configuration exist yet).A workaround is to construct the ARN manually (with adjustments if the Log Group is in another account/region):
The text was updated successfully, but these errors were encountered: