【发布时间】:2021-05-01 20:46:11
【问题描述】:
我正在将我们的 cloudformation 堆栈扩展到一个新区域,但希望在我们的 elasticsearch 集群中启用加密。但是,我只想为新区域启用它
我试过这个:
Conditions:
EnableEnhancedSecurity:
!Not
- !Equals
- 'us-east-1'
- { Ref: AWS::Region }
Resources:
MyTestingElasticSearchStore:
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Fn::Sub: 'stack-${AWS::Region}-${Stage}'
ElasticsearchVersion: '7.1'
ElasticsearchClusterConfig:
EncryptionAtRestOptions:
Enabled:
!If
- EnableEnhancedSecurity
- 'true'
- 'false'
NodeToNodeEncryptionOptions:
Enabled:
!If
- EnableEnhancedSecurity
- 'true'
- 'false'
...
但是当我尝试更新我的测试堆栈时出现以下错误:CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename stack-us-west-1-test and update the stack again.
我认为这是因为我正在添加属性(即使它们是“假”)所以我试图了解如何有条件地添加属性。
我正在尝试:
Conditions:
EnableEnhancedSecurity:
!Not
- !Equals
- 'us-east-1'
- { Ref: AWS::Region }
Resources:
MyTestingElasticSearchStore:
Type: "AWS::Elasticsearch::Domain"
Properties:
DomainName:
Fn::Sub: 'stack-${AWS::Region}-${Stage}'
ElasticsearchVersion: '7.1'
ElasticsearchClusterConfig:
...
Fn::If: # only add the properties if needed
- EnableEnhancedSecurity
-
EncryptionAtRestOptions:
Enabled: 'true'
NodeToNodeEncryptionOptions:
Enabled: 'true'
- { Ref: AWS::NoValue }
但遇到以下错误:
YAML Errors:
while parsing a block mapping
in "<unicode string>", line 76, column 5:
Type: "AWS::Elasticsearch::Domain"
^
expected <block end>, but found '<block sequence start>'
in "<unicode string>", line 148, column 6:
- { Ref: AWS::NoValue }
这甚至可能吗?如果是这样,我如何在不通过 cloudformation 触及现有区域的情况下仅在新区域中进行设置?
【问题讨论】:
标签: amazon-web-services yaml amazon-cloudformation