简体   繁体   English

资源名称中没有前缀/后缀的CloudFormation(即CloudWatch Log Groups)

[英]CloudFormation without prefix/suffix in resource names (i.e. CloudWatch Log Groups)

I'm creating a stack with CloudFormation. 我正在使用CloudFormation创建堆栈。 When you create log groups, it automatically adds prefixes and suffixes to my log group names. 创建日志组时,它将自动在我的日志组名称中添加前缀和后缀。 For example, if I try to create log group MyLogGroup , it creates log group my-stack-name-MyLogGroup-EEWJYSCJRK2V . 例如,如果我尝试创建日志组MyLogGroup ,它将创建日志组my-stack-name-MyLogGroup-EEWJYSCJRK2V

I understand that for a lot of use cases, this might be desired to differentiate the same resources for different stacks. 我了解对于许多用例,可能需要这样做以区分相同资源用于不同堆栈。 However, my team has different accounts for our different stacks, so there will be no overlap. 但是,我的团队为不同的堆栈使用不同的帐户,因此不会有重叠。 Having dynamic prefixes and suffixes makes it hard to reference log groups from static files (ie CloudWatch Logs agent config file). 具有动态前缀和后缀使得很难从静态文件(即CloudWatch Logs代理配置文件)中引用日志组。

Is there a way to make sure that resources get named EXACTLY what I put and not add a prefix or suffix? 有没有一种方法可以确保资源完全按照我的名字命名,而不添加前缀或后缀?

We have run into this same issue with our AWS ecosystem and after speaking to several folks at AWS, this is by design and is not modifiable right now. 我们的AWS生态系统也遇到了同样的问题,在与AWS的几个人交谈后,这是设计使然,目前无法修改。

Depending on the complexity of what you are trying to do, I would recommend replacing CloudFormation with some Lambda functions to manage the resources (can be done cross account with sts:AssumeRole). 根据您要执行的操作的复杂性,我建议用一些Lambda函数替换CloudFormation以管理资源(可以使用sts:AssumeRole跨帐户完成)。

Yes its possible. 是的,它有可能。 For instance in our cloud formation template we create the cloud watch conf file with log_group_name and log_stream_name parameter set to combination of different parameters. 例如,在我们的云形成模板中,我们创建了将log_group_name和log_stream_name参数设置为不同参数组合的云监视conf文件。 Our log groups are created without prefix and postfix. 我们的日志组创建时没有前缀和后缀。 See following example: 请参见以下示例:

"log_group_name = "MyLogGroup\n",
"log_stream_name = {instance_id}/", "MyLogGroup", ".log\n",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM