|
| 1 | +/*+ exists, retries=3, retry_delay=5 */ |
| 2 | +SELECT COUNT(*) as count |
| 3 | +FROM aws.s3.buckets |
| 4 | +WHERE region = '{{ region }}' |
| 5 | +AND data__Identifier = '{{ bucket_name }}' |
| 6 | + |
| 7 | +/*+ create */ |
| 8 | +INSERT INTO aws.s3.buckets ( |
| 9 | + BucketName, |
| 10 | + OwnershipControls, |
| 11 | + AccessControl, |
| 12 | + BucketEncryption, |
| 13 | + PublicAccessBlockConfiguration, |
| 14 | + VersioningConfiguration, |
| 15 | + Tags, |
| 16 | + region |
| 17 | +) |
| 18 | +SELECT |
| 19 | + '{{ bucket_name }}', |
| 20 | + '{{ ownership_controls }}', |
| 21 | + '{{ access_control }}', |
| 22 | + '{{ bucket_encryption }}', |
| 23 | + '{{ public_access_block_configuration }}', |
| 24 | + '{{ versioning_configuration }}', |
| 25 | + '{{ global_tags }}', |
| 26 | + '{{ region }}' |
| 27 | + |
| 28 | +/*+ update */ |
| 29 | +update aws.s3.buckets |
| 30 | +set data__PatchDocument = string('{{ { |
| 31 | + "OwnershipControls": ownership_controls, |
| 32 | + "AccessControl": access_control, |
| 33 | + "BucketEncryption": bucket_encryption, |
| 34 | + "PublicAccessBlockConfiguration": public_access_block_configuration, |
| 35 | + "VersioningConfiguration": versioning_configuration, |
| 36 | + "Tags": global_tags |
| 37 | + } | generate_patch_document }}') |
| 38 | +WHERE |
| 39 | +region = '{{ region }}' |
| 40 | +AND data__Identifier = '{{ bucket_name }}' |
| 41 | + |
| 42 | +/*+ statecheck, retries=5, retry_delay=5 */ |
| 43 | +SELECT COUNT(*) as count FROM ( |
| 44 | + SELECT |
| 45 | + JSON_EQUAL(ownership_controls, '{{ ownership_controls }}') as test_ownership_controls, |
| 46 | + JSON_EQUAL(bucket_encryption, '{{ bucket_encryption }}') as test_encryption, |
| 47 | + JSON_EQUAL(public_access_block_configuration, '{{ public_access_block_configuration }}') as test_public_access_block_configuration, |
| 48 | + JSON_EQUAL(versioning_configuration, '{{ versioning_configuration }}') as test_versioning_configuration |
| 49 | + FROM aws.s3.buckets |
| 50 | + WHERE region = '{{ region }}' |
| 51 | + AND data__Identifier = '{{ bucket_name }}' |
| 52 | + AND access_control = '{{ access_control }}')t |
| 53 | +WHERE test_ownership_controls = 1 |
| 54 | +AND test_encryption = 1 |
| 55 | +AND test_public_access_block_configuration = 1 |
| 56 | +AND test_versioning_configuration = 1 |
| 57 | + |
| 58 | +/*+ exports, retries=3, retry_delay=5 */ |
| 59 | +SELECT |
| 60 | +arn as bucket_arn |
| 61 | +FROM aws.s3.buckets |
| 62 | +WHERE region = '{{ region }}' |
| 63 | +AND data__Identifier = '{{ bucket_name }}' |
0 commit comments