![](/img/trans.png)
[英]what is the total no of resources can we create in single cloud formation template?
[英]Create DynamoDB through custom resources Cloud Formation Template
我正在嘗試使用以下Cloud Formation模板腳本在AWS DynamoDB中創建GlobalTable。 但是我不確定我是否需要所有的東西。 我的自定義資源部分如下所示。
"CreateGlobalTable":{
"Type":"Custom::CreateGlobalTable",
"Properties":{
"ServiceToken":{
"Fn::GetAtt":[
"SolutionHelper",
"Arn"
]
},
"GlobalTableName": "myglobaltable",
"ReplicationGroup": [
{
"RegionName": "eu-west-1"
}
]
}
},
生成堆棧時,我在日志中看到相同的條目,但是沒有創建全局表。 它是否需要一個支持lamda函數,它實際上會創建全局表? 或AWS API從上面定義的方式自動處理它。 任何指導都非常感謝。
實際上,您實際上需要一個Lambda函數來實際創建/更新/刪除GlobalTable。
以下是如何進行的基本指導:
GlobalTableCustomResourceLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Handler: global_table_custom_resource.lambda_handler
Role: !GetAtt CustomResourceRole.Arn
Code: cloudformation/custom-resource/global_table_custom_resource.py
Runtime: python3.6
Timeout: '25'
CustomResourceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: ''
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
Path: "/"
Policies:
- PolicyName: GlobalTableCustomResourceLambdaPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:CreateTable
- dynamodb:UpdateTable
- dynamodb:DeleteTable
Resource: "*"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
對於Python代碼,我認為它超出了StackOverflow答案的范圍,我將向您介紹貫穿整個過程的本文: https : //serverlesscode.com/post/python-custom-resource-cloudformation/ 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.