AWS DataSync Location S3

This page shows how to write Terraform and CloudFormation for DataSync Location S3 and write them securely.

aws_datasync_location_s3 (Terraform)

The Location S3 in DataSync can be configured in Terraform with the resource name aws_datasync_location_s3. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub
resource "aws_datasync_location_s3" "source_location" {
  s3_bucket_arn = aws_s3_bucket.datasync_bucket.arn
  subdirectory  = "/source"

  s3_config {
    bucket_access_role_arn = aws_iam_role.datasync_bucket_access_role.arn
resource "aws_datasync_location_s3" "this" {
  s3_bucket_arn = var.s3_bucket_arn
  subdirectory  = var.subdirectory
  tags          = var.tags

  dynamic "s3_config" {
resource "aws_datasync_location_s3" "example" {
  s3_bucket_arn = aws_s3_bucket.example.arn
  subdirectory  = "/example/prefix"

  s3_config {
    bucket_access_role_arn = aws_iam_role.example.arn
resource "aws_datasync_location_s3" "wordpress_datasync_location_s3" {
  s3_bucket_arn = aws_s3_bucket.wordpress_s3_bucket.arn
  subdirectory  = "/"

  s3_config {
    bucket_access_role_arn = aws_iam_role.wp_iam_role_s3_dc.arn
resource "aws_datasync_location_s3" "backup" {
  s3_bucket_arn = aws_s3_bucket.backup.arn
  subdirectory  = "/minecraft"

  s3_config {
    bucket_access_role_arn = aws_iam_role.backup.arn

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


Explanation in Terraform Registry

Manages an S3 Location within AWS DataSync.

AWS::DataSync::LocationS3 (CloudFormation)

The LocationS3 in DataSync can be configured in CloudFormation with the resource name AWS::DataSync::LocationS3. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.


Explanation in CloudFormation Registry

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

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

Frequently asked questions

What is AWS DataSync Location S3?

AWS DataSync Location S3 is a resource for DataSync of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS DataSync Location S3?

For Terraform, the nhsconnect/prm-practice-migration-data-pipeline-prototype, niveklabs/aws and shaikis/terraform-aws-datasync source code examples are useful. See the Terraform Example section for further details.