我了解AWS CLI可以使用config和credentials文件来存储它的本地配置文件配置.
有没有人知道关于每个文件应该包含哪些内容的任何一般指导和/或最佳实践?
我一直在尝试以YAML格式编写一些AWS CloudFormation模板.
我一直遇到CloudFormation尝试解析IAM策略变量的问题,例如${aws:username},与替换一起使用.一个例子如下:
CommonUserGroup:
Type: AWS::IAM::Group
Properties:
GroupName: Common
Path: /project/
Policies:
- PolicyName: ClusterPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: "iam:GetAccountPasswordPolicy"
Resource: "*"
- Effect: Allow
Action: "iam:ChangePassword"
Resource: !Sub 'arn:aws:iam::${AWS::AccountId}:user/${aws:username}'
Run Code Online (Sandbox Code Playgroud)
使用CloudFormation模板尝试创建堆栈时,将返回以下错误:
Template validation error: Template format error: Unresolved resource dependencies [aws:username] in the Resources block of the template
Run Code Online (Sandbox Code Playgroud)
如果我手动指定用户名,而不是使用策略变量,如:
'arn:aws:iam::${AWS::AccountId}:user/bob'
Run Code Online (Sandbox Code Playgroud)
然后错误就消失了.
有没有办法可以逃避策略变量,以便CloudFormation不会尝试将它们解析为模板的一部分?