Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Cloudformation Template - Set Region in S3 Bucket

I'm trying to create an s3 bucket in a specific region (us-west-2). This doesn't seem possible using Cloudformation Templates. Any ideas? I have had no luck explicitly naming it using the service-region-hash convention that i read about.

 Template:
 {
     "AWSTemplateFormatVersion": "2010-09-09",
     "Resources": {
       "S3Bucket": {
         "Type": "AWS::S3::Bucket",
         "Properties": {
           "AccessControl": "PublicReadWrite",
         }
       }
     },
     "Outputs": {
       "BucketName": {
         "Value": {
           "Ref": "S3Bucket"
         },
         "Description": "Name of the sample Amazon S3 bucket with a lifecycle configuration."
       }
     }
   }
like image 879
FrumkinWY Avatar asked Sep 20 '16 07:09

FrumkinWY


People also ask

Are CloudFormation templates region specific?

The end point URL for CloudFormation is region based and AFAIK there isn't a place whether you can specify an region specific (diff region) information.

Is S3 Bucket specific to region?

Amazon S3 supports global buckets, which means that each bucket name must be unique across all AWS accounts in all the AWS Regions within a partition.

What is default region for S3 bucket?

If you don't specify a Region when you create a client or a bucket, Amazon S3 uses the default Region US East (N. Virginia). To create a client to access a dual-stack endpoint, you must specify an AWS Region.


1 Answers

If you want to create the s3 bucket in a specific region, you need to run the Cloudformation JSON template from this region.

The end point URLs for cloudFormation are Region based (https://aws.amazon.com/cloudformation/faqs/?nc1=h_ls#regions and http://docs.aws.amazon.com/general/latest/gr/rande.html#cfn_region) and you cannot as for today cross check region.

I saw it has been discussed few times on aws support thread so might be something that will be done in future

The bucket is created within 1 region and when you need to access it you need to pass the region to the s3 end-point.

If you want to enable cross-region replication you can do that from the cloud formation template with the ReplicationConfiguration properties

like image 116
Frederic Henri Avatar answered Oct 23 '22 01:10

Frederic Henri