AWS::DataSync::LocationS3 - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.


The AWS::DataSync::LocationS3 resource specifies an endpoint for an Amazon S3 bucket.

For more information, see Create an Amazon S3 location in the Amazon DataSync User Guide.


To declare this entity in your Amazon CloudFormation template, use the following syntax:


{ "Type" : "AWS::DataSync::LocationS3", "Properties" : { "S3BucketArn" : String, "S3Config" : S3Config, "S3StorageClass" : String, "Subdirectory" : String, "Tags" : [ Tag, ... ] } }


Type: AWS::DataSync::LocationS3 Properties: S3BucketArn: String S3Config: S3Config S3StorageClass: String Subdirectory: String Tags: - Tag



The ARN of the Amazon S3 bucket.

Required: Yes

Type: String

Maximum: 156

Pattern: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):(s3|s3-outposts):[a-z\-0-9]*:[0-9]*:.*$

Update requires: Replacement


The Amazon Resource Name (ARN) of the Amazon Identity and Access Management (IAM) role that is used to access an Amazon S3 bucket.

For detailed information about using such a role, see Creating a Location for Amazon S3 in the Amazon DataSync User Guide.

Required: Yes

Type: S3Config

Update requires: Replacement


The Amazon S3 storage class that you want to store your files in when this location is used as a task destination. For buckets in Amazon Web Services Regions, the storage class defaults to S3 Standard.

For more information about S3 storage classes, see Amazon S3 Storage Classes. Some storage classes have behaviors that can affect your S3 storage costs. For detailed information, see Considerations When Working with Amazon S3 Storage Classes in DataSync.

Required: No

Type: String


Update requires: Replacement


A subdirectory in the Amazon S3 bucket. This subdirectory in Amazon S3 is used to read data from the S3 source location or write data to the S3 destination.

Required: No

Type: String

Maximum: 4096

Pattern: ^[a-zA-Z0-9_\-\+\./\(\)\p{Zs}]*$

Update requires: Replacement


The key-value pair that represents the tag that you want to add to the location. The value can be an empty string. We recommend using tags to name your resources.

Required: No

Type: List of Tag

Maximum: 50

Update requires: No interruption

Return values


When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the location resource Amazon Resource Name (ARN). For example:


For more information about using the Ref function, see Ref.


The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.


The Amazon Resource Name (ARN) of the specified Amazon S3 location.


The URI of the specified Amazon S3 location.


Create an Amazon S3 location for DataSync

The following example specifies an S3 location for DataSync. In this example, the S3 location uses the bucket specified by the Amazon Resource Name (ARN) arn:aws:s3:::MyBucket. The access role is specified by the ARN arn:aws:iam::111222333444:role/MyBucketAccessRole. The example uses the S3 Standard storage class and refers to the subdirectory /MyFolder.

Amazon Security Token Service (Amazon STS) must be activated in your account and Region for DataSync to assume the IAM role. For more information about temporary security credentials, see Temporary security credentials in IAM in the IAM User Guide.


{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Specifies an S3 location for DataSync", "Resources": { "LocationS3": { "Type": "AWS::DataSync::LocationS3", "Properties": { "S3BucketArn": "arn:aws:s3:::MyBucket", "S3Config": { "BucketAccessRoleArn": "arn:aws:iam::111222333444:role/MyBucketAccessRole" }, "S3StorageClass": "STANDARD", "Subdirectory": "/MyFolder" } } } }


AWSTemplateFormatVersion: 2010-09-09 Description: Specifies an S3 location for DataSync Resources: LocationS3: Type: AWS::DataSync::LocationS3 Properties: S3BucketArn: arn:aws:s3:::MyBucket S3Config: BucketAccessRoleArn: arn:aws:iam::111222333444:role/MyBucketAccessRole S3StorageClass: STANDARD Subdirectory: /MyFolder