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

Tags not set if many resources in SLS / CloudFormation stack #5

Open
Ilnore opened this issue Mar 24, 2023 · 1 comment
Open

Tags not set if many resources in SLS / CloudFormation stack #5

Ilnore opened this issue Mar 24, 2023 · 1 comment

Comments

@Ilnore
Copy link

Ilnore commented Mar 24, 2023

If an SLS / CloudFormation stack has many resources (more than 100), this plugin will not reliably set CloudWatch log group tags.

The root cause is this:

getStackResources() {
return new Promise((resolve, reject) => {
this.cloudWatchLogsService.describeStackResources({ StackName: this.stackName }, (err, data) => {
if (err) return reject(err);
resolve(data);
});
});
}

Quoting the AWS SDK documentation for CloudFormation.describeStackResources:

Note: Only the first 100 resources will be returned. If your stack has more resources than this, you should use ListStackResources instead.

So only the first 100 resources in a stack get considered for tagging. If the stack has more than 100 resources, it's pretty much random if the log groups are returned within the first 100, and if they are returned, then they will get the tags, and if they do not fit into the 100, then they're ignored and no tags are set.

Proposed solution:

As hinted by CloudFormation.describeStackResources documentation, we should use CloudFormation.listStackResources here instead.

@Ilnore
Copy link
Author

Ilnore commented Mar 27, 2023

Looks like this has been fixed in a fork of this repo, which is served in NPM as serverless-tag-cloud-watch-log-groups.

https://github.com/randomhash/serverless-tag-cloud-watch-logs/blob/59dac5860a9ca2e8d3db9c9bd223ba55b8101c46/index.js#L66-L76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant