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 (PDF).


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: No

Type: String

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

Maximum: 156

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


Specifies a prefix in the S3 bucket that DataSync reads from or writes to (depending on whether the bucket is a source or destination location).


DataSync can't transfer objects with a prefix that begins with a slash (/) or includes //, /./, or /../ patterns. For example:

  • /photos

  • photos//2006/January

  • photos/./2006/February

  • photos/../2006/March

Required: No

Type: String

Pattern: ^[\p{L}\p{M}\p{Z}\p{S}\p{N}\p{P}\p{C}]*$

Maximum: 1024

Update requires: Replacement


Specifies labels that help you categorize, filter, and search for your Amazon resources. We recommend creating at least a name tag for your transfer location.

Required: No

Type: Array 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