Skip to content

Commit

Permalink
upd: WIP testing for datasync task reports
Browse files Browse the repository at this point in the history
  • Loading branch information
rizkybiz committed Oct 10, 2023
1 parent e333fe2 commit 238155e
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions internal/service/datasync/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ func TestAccDataSyncTask_DefaultSyncOptions_verifyMode(t *testing.T) {
})
}

func TestAccDataSyncTask_report_config(t *testing.T) {

}

func TestAccDataSyncTask_tags(t *testing.T) {
acctest.Skip(t, "Tagging on creation is inconsistent")
var task1, task2, task3 datasync.DescribeTaskOutput
Expand Down Expand Up @@ -978,6 +982,83 @@ resource "aws_datasync_task" "test" {
`, rName, cron))
}

func testAccTaskReportConfig(rName string) string {
return acctest.ConfigCompose(
testAccTaskDestinationLocationS3BaseConfig(rName),
testAccTaskSourceLocationNFSBaseConfig(rName),
fmt.Sprintf(`
resource "aws_s3_bucket" "task_report_destination" {
bucket = "%[1]s-task-report-destination"
force_destroy = true
}
resource "aws_s3_object "subdirectory" {
bucket = "%[1]s-task-report-destination"
key = "reports"
source = "/dev/null"
}
resource "aws_iam_role" "destination_bucket_role" {
name = "%[1]s-destination-role"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"Service": "datasync.amazonaws.com"
},
"Action": "sts:AssumeRole"
}]
}
POLICY
}
resource "aws_iam_role_policy" "destination_bucket_policy" {
role = aws_iam_role.destination_bucket_role.id
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Resource": [
"${aws_s3_bucket.task_report_destination.arn}",
"${aws_s3_bucket.task_report_destination.arn}/*"
]
}]
}
POLICY
}
resource "aws_datasync_task" "test" {
destination_location_arn = aws_datasync_location_s3.destination.arn
name = %[1]q
source_location_arn = aws_datasync_location_nfs.source.arn
task_report_config {
s3_destination {
bucket_access_role_arn = "aws_iam_role.destination_bucket_role.arn"
s3_bucket_arn = "aws_s3_bucket.task_report_destination.arn"
subdirectory = "reports"
}
s3_object_versioning = "NONE"
output_type = "STANDARD"
report_overrides {
deleted_override = "SUCCESSES_AND_ERRORS"
skipped_override = "SUCCESSES_AND_ERRORS"
transferred_override = "SUCCESSES_AND_ERRORS"
verified_override = "SUCCESSES_AND_ERRORS"
}
report_level = "SUCCESSES_AND_ERRORS"
}
}
`, rName),
)
}

func testAccTaskCloudWatchLogGroupARNConfig(rName string) string {
return acctest.ConfigCompose(
testAccTaskDestinationLocationS3BaseConfig(rName),
Expand Down

0 comments on commit 238155e

Please sign in to comment.