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

(aws-logs,aws-elasticsearch): Unable to pass the dynamically fetched Elastic Search domain Arn when creating a Subscription Filter. #27346

Closed
aashishgk7760 opened this issue Sep 29, 2023 · 1 comment
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@aashishgk7760
Copy link

Describe the bug

I am creating a Elastic Search Domain and then for the log groups I am trying to create a subscription filter . Below is the sample code


const devDomain = new es.CfnDomain(this, 'devDomain', {
elasticsearchVersion: '7.10',

})

for (const log_groupname of log_groups) {
const logGroup = logs.LogGroup.fromLogGroupName(this, 'log_group', log_groupname)

new logs.CfnSubscriptionFilter(this, 'log_groupa', {
logGroupName: logGroup.logGroupName,
filterPattern: '',
destinationArn: devDomain.domainArn, even though it is type string and is expecting string
roleArn: '0000000000000000000000000:role/service-role/sample-role-arn'

})
}

I am getting the following error when I pass it as above for destinationArn props. Also the reason for using L1 construct is that i would not able to pass the open search as the destination for the props destination[1]

[1] https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogSubscriptionDestination.html

===ERROR===
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2322)
logs.generated.d.ts(856, 14): The expected type comes from property 'destinationArn' which is declared here on type 'CfnSubscriptionFilterProps'
(property) CfnSubscriptionFilterProps.destinationArn: string
===ERROR===

Expected Behavior

We should be able to fetch the CfnDomain Arn and also not sure why am i getting Domain which is L2 as deprecated. I am using cdk version 2.99.0 (build 0aa1096)

Current Behavior

const devDomain = new es.CfnDomain(this, 'devDomain', {
elasticsearchVersion: '7.10',

})

for (const log_groupname of log_groups) {
const logGroup = logs.LogGroup.fromLogGroupName(this, 'log_group', log_groupname)

new logs.CfnSubscriptionFilter(this, 'log_groupa', {
logGroupName: logGroup.logGroupName,
filterPattern: '',
destinationArn: devDomain.domainArn, even though it is type string and is expecting string
roleArn: '0000000000000000000000000:role/service-role/sample-role-arn'

})
}

I am getting the following error when I pass it as above for destinationArn props. Also the reason for using L1 construct is that i would not able to pass the open search as the destination for the props destination[1]

[1] https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_logs.ILogSubscriptionDestination.html

===ERROR===
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.ts(2322)
logs.generated.d.ts(856, 14): The expected type comes from property 'destinationArn' which is declared here on type 'CfnSubscriptionFilterProps'
(property) CfnSubscriptionFilterProps.destinationArn: string
===ERROR===

Reproduction Steps

const devDomain = new es.CfnDomain(this, 'devDomain', {
elasticsearchVersion: '7.10',

})

for (const log_groupname of log_groups) {
const logGroup = logs.LogGroup.fromLogGroupName(this, 'log_group', log_groupname)

new logs.CfnSubscriptionFilter(this, 'log_groupa', {
logGroupName: logGroup.logGroupName,
filterPattern: '',
destinationArn: devDomain.domainArn, even though it is type string and is expecting string
roleArn: '0000000000000000000000000:role/service-role/sample-role-arn'

})
}

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.99.0 (build 0aa1096)

Framework Version

No response

Node.js Version

v20.5.1

OS

MacOs

Language

Typescript

Language Version

Version 4.9.5

Other information

No response

@aashishgk7760 aashishgk7760 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 29, 2023
@github-actions github-actions bot added the @aws-cdk/aws-logs Related to Amazon CloudWatch Logs label Sep 29, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant