gpt4 book ai didi

amazon-s3 - Cloudformation S3bucket 创建

转载 作者:行者123 更新时间:2023-12-03 07:17:31 25 4
gpt4 key购买 nike

这是我编写的用于创建简单S3存储桶的cloudformation模板,如何指定存储桶的名称?这是正确的方法吗?

{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Simple S3 Bucket",
"Parameters": {
"OwnerService": {
"Type": "String",
"Default": "CloudOps",
"Description": "Owner or service name. Used to identify the owner of the vpc stack"
},
"ProductCode": {
"Type": "String",
"Default": "cloudops",
"Description": "Lowercase version of the product code (i.e. jem). Used for tagging"
},
"StackEnvironment": {
"Type": "String",
"Default": "stage",
"Description": "Lowercase version of the environment name (i.e. stage). Used for tagging"
}
},
"Mappings": {
"RegionMap": {
"us-east-1": {
"ShortRegion": "ue1"
},
"us-west-1": {
"ShortRegion": "uw1"
},
"us-west-2": {
"ShortRegion": "uw2"
},
"eu-west-1": {
"ShortRegion": "ew1"
},
"ap-southeast-1": {
"ShortRegion": "as1"
},
"ap-northeast-1": {
"ShortRegion": "an1"
},
"ap-northeast-2": {
"ShortRegion": "an2"
}
}
},
"Resources": {
"JenkinsBuildBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": {
"Fn::Join": [
"-",
[
{
"Ref": "ProductCode"
},
{
"Ref": "StackEnvironment"
},
"deployment",
{
"Fn::FindInMap": [
"RegionMap",
{
"Ref": "AWS::Region"
},
"ShortRegion"
]
}
]
]
},
"AccessControl": "Private"
},
"DeletionPolicy": "Delete"
}
},
"Outputs": {
"DeploymentBucket": {
"Description": "Bucket Containing Chef files",
"Value": {
"Ref": "DeploymentBucket"
}
}
}
}

最佳答案

这是一个非常简单的 Cloudformation 模板,用于创建 S3 存储桶,包括定义存储桶名称。

AWSTemplateFormatVersion: '2010-09-09'
Description: create a single S3 bucket

Resources:
SampleBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: sample-bucket-0827-cc

如果您希望 AWS 为您命名存储桶,您也可以保留“Properties: BucketName”行。然后它看起来像 $StackName-SampleBucket-$uniqueIdentifier。

希望这有帮助。

关于amazon-s3 - Cloudformation S3bucket 创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42978948/

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