我正在創建一個多租戶架構。每當新租戶注冊我的平臺時,我都需要復制我的資源。
我在我的 SAM 專案中創建了一個堆疊集,如下所示:
StackSet:
Type: AWS::CloudFormation::StackSet
Properties:
Capabilities:
- "CAPABILITY_IAM"
- "CAPABILITY_NAMED_IAM"
- "CAPABILITY_AUTO_EXPAND"
AdministrationRoleARN: !GetAtt AdministrationRole.Arn
ExecutionRoleName: !Ref ExecutionRole
OperationPreferences:
FailureToleranceCount: 0
MaxConcurrentCount: 1
PermissionModel: 'SELF_MANAGED'
StackInstancesGroup:
- DeploymentTargets:
Accounts:
- !Ref AWS::AccountId
Regions:
- !Ref AWS::Region
- DeploymentTargets:
Accounts:
- !Ref AWS::AccountId
Regions:
- !Ref AWS::Region
Tags:
-
Key: 'PROJECT'
Value: 'imaclegal'
StackSetName: 'imaclegal'
TemplateURL: 'https://s3.amazonaws.com/a-child-s3/output.yaml'
當我執行時,sam deploy我收到此錯誤:
資源 StackSet 的屬性驗證失敗,訊息為:#: #: only 1 subschema matching out of 2 #/StackInstancesGroup: array items are not unique
所以似乎我無法在同一個 AWS 賬戶和區域中部署 1 個以上的實體,有沒有辦法在同一個 AWS 賬戶和區域中完成多個實體?或者有沒有其他更好的方法來為我的新租戶復制我的資源?
uj5u.com熱心網友回復:
如果您想將所有資源保存在單個賬戶/區域中,CloudFormation StackSets 目前無法滿足您的需求。如果您的資源未在模板中命名,您可以創建多個 CloudFormation 堆疊。但是,這可能會使維護變得混亂,并且如果您大規模運行應用程式,則更有可能達到服務配額。
我個人建議使用 AWS Organizations 為每個租戶創建一個賬戶。然后可以使用 CloudFormation StackSets 自動將您的資源復制到新帳戶。
該解決方案還具有為每個租戶更精確的成本分配的額外好處。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/349188.html
