AWS DataSync Location S3

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


Fix issues in your cloud & app configurations

Test for misconfigurations of this resource in your cloud.


Terraform Example (aws_datasync_location_s3)

Manages an S3 Location within AWS DataSync.


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

CloudFormation Example (AWS::DataSync::LocationS3)

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.