gpt4 book ai didi

amazon-web-services - CloudFormation 中的条件 Dynamo 全局表

转载 作者:行者123 更新时间:2023-12-03 07:22:32 24 4
gpt4 key购买 nike

我试图弄清楚如何在条件成立的情况下拥有全局 Dynamo 表,否则拥有常规 Dynamo 表。然而,linter 提示其有效性:预期有一个 block ,但在属性处得到了...。这是我的代码:

Resources:
ClientNameTable:
!If
- SingleEnv
- Type: AWS::DynamoDB::GlobalTable
- Type: AWS::DynamoDB:Table

Properties:
TableName: ClientNameTest
AttributeDefinitions:
- AttributeName: uuuuu
AttributeType: S
- AttributeName: xxxxx
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: uuuuu
KeyType: HASH
- AttributeName: xxxxx
KeyType: RANGE
StreamSpecification:
StreamViewType: NEW_IMAGE
TimeToLiveSpecification:
AttributeName: time_to_live
Enabled: true
Replicas:
!If
- SingleEnv
- Region: us-east-1
- Region: us-west-2
- !Ref "AWS::NoValue"

最佳答案

你不能这样写 If 。相反,您必须拥有两个独立的资源。

Resources:
ClientNameTable:
Condition: SingleEnv
Properties:
TableName: ClientNameTest
AttributeDefinitions:
- AttributeName: uuuuu
AttributeType: S
- AttributeName: xxxxx
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: uuuuu
KeyType: HASH
- AttributeName: xxxxx
KeyType: RANGE
StreamSpecification:
StreamViewType: NEW_IMAGE
TimeToLiveSpecification:
AttributeName: time_to_live
Enabled: true
Replicas:
!If
- SingleEnv
- Region: us-east-1
- Region: us-west-2
- !Ref "AWS::NoValue"


ClientNameTable:
Condition: NotSingleEnv
Properties:
TableName: ClientNameTest
AttributeDefinitions:
- AttributeName: uuuuu
AttributeType: S
- AttributeName: xxxxx
AttributeType: S
BillingMode: PAY_PER_REQUEST
KeySchema:
- AttributeName: uuuuu
KeyType: HASH
- AttributeName: xxxxx
KeyType: RANGE
StreamSpecification:
StreamViewType: NEW_IMAGE
TimeToLiveSpecification:
AttributeName: time_to_live
Enabled: true
Replicas:
!If
- SingleEnv
- Region: us-east-1
- Region: us-west-2
- !Ref "AWS::NoValue"

您必须在Conditions中创建NotSingleEnv

关于amazon-web-services - CloudFormation 中的条件 Dynamo 全局表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73130143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com