diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8ad5bde..0eac067f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,77 +52,3 @@ jobs: module-change-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/** module-asset-exclude-patterns: .gitignore,*.md,*.tftest.hcl,tests/** use-ssh-source-format: true - - - name: Test Action Outputs - id: test-outputs - run: | - echo "Testing action outputs..." - - # Test if outputs are set - if [[ -n "${{ steps.test-action.outputs.changed-module-names }}" ]]; then - echo "✅ Output 'changed-modules-names': ${{ steps.test-action.outputs.changed-module-names }}" - else - echo "❌ No changed module names found" - fi - - if [[ -n "${{ steps.test-action.outputs.changed-module-paths }}" ]]; then - echo "✅ Output 'changed-module-paths': ${{ steps.test-action.outputs.changed-module-paths }}" - else - echo "❌ No changed module paths found" - fi - - if [[ -n "${{ steps.test-action.outputs.changed-modules-map }}" ]]; then - echo "✅ Output 'changed-modules-map':" - echo '${{ steps.test-action.outputs.changed-modules-map }}' | jq -r ' - "Found \(length) changed module(s):", - (to_entries[] | - "• \(.key):", - " - Path: \(.value.path)", - " - Current Tag: \(.value.currentTag)", - " - Next Tag: \(.value.nextTag)", - " - Release Type: \(.value.releaseType)" - ) - ' - else - echo "❌ No changed modules map found" - fi - - # Silently validate JSON structure is an object - echo '${{ steps.test-action.outputs.changed-modules-map }}' | jq -e 'type == "object"' > /dev/null || { - echo "❌ Expected object type in changed-modules-map" - exit 1 - } - - # Test new outputs for all modules - if [[ -n "${{ steps.test-action.outputs.all-module-names }}" ]]; then - echo "✅ Output 'all-module-names': ${{ steps.test-action.outputs.all-module-names }}" - else - echo "❌ No all module names found" - fi - - if [[ -n "${{ steps.test-action.outputs.all-module-paths }}" ]]; then - echo "✅ Output 'all-module-paths': ${{ steps.test-action.outputs.all-module-paths }}" - else - echo "❌ No all module paths found" - fi - - if [[ -n "${{ steps.test-action.outputs.all-modules-map }}" ]]; then - echo "✅ Output 'all-modules-map':" - echo '${{ steps.test-action.outputs.all-modules-map }}' | jq -r ' - "Found \(length) total module(s):", - (to_entries[] | - "• \(.key):", - " - Path: \(.value.path)", - " - Latest Tag: \(.value.latestTag)", - " - Latest Tag Version: \(.value.latestTagVersion)" - ) - ' - else - echo "❌ No all modules map found" - fi - - # Silently validate JSON structure is an objects - echo '${{ steps.test-action.outputs.all-modules-map }}' | jq -e 'type == "object"' > /dev/null || { - echo "❌ Expected object type in all-modules-map" - exit 1 - } diff --git a/screenshots/test copy 2/1 b/screenshots/test copy 2/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy b/screenshots/test copy 2/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 10 b/screenshots/test copy 2/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 11 b/screenshots/test copy 2/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 12 b/screenshots/test copy 2/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 13 b/screenshots/test copy 2/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 14 b/screenshots/test copy 2/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 15 b/screenshots/test copy 2/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 16 b/screenshots/test copy 2/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 17 b/screenshots/test copy 2/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 18 b/screenshots/test copy 2/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 19 b/screenshots/test copy 2/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 2 b/screenshots/test copy 2/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 20 b/screenshots/test copy 2/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 21 b/screenshots/test copy 2/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 22 b/screenshots/test copy 2/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 23 b/screenshots/test copy 2/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 24 b/screenshots/test copy 2/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 25 b/screenshots/test copy 2/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 26 b/screenshots/test copy 2/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 27 b/screenshots/test copy 2/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 28 b/screenshots/test copy 2/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 29 b/screenshots/test copy 2/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 3 b/screenshots/test copy 2/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 30 b/screenshots/test copy 2/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 31 b/screenshots/test copy 2/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 32 b/screenshots/test copy 2/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 33 b/screenshots/test copy 2/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 34 b/screenshots/test copy 2/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 35 b/screenshots/test copy 2/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 4 b/screenshots/test copy 2/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 5 b/screenshots/test copy 2/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 6 b/screenshots/test copy 2/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 7 b/screenshots/test copy 2/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 8 b/screenshots/test copy 2/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 2/1 copy 9 b/screenshots/test copy 2/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 b/screenshots/test copy 3/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy b/screenshots/test copy 3/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 10 b/screenshots/test copy 3/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 11 b/screenshots/test copy 3/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 12 b/screenshots/test copy 3/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 13 b/screenshots/test copy 3/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 14 b/screenshots/test copy 3/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 15 b/screenshots/test copy 3/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 16 b/screenshots/test copy 3/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 17 b/screenshots/test copy 3/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 18 b/screenshots/test copy 3/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 19 b/screenshots/test copy 3/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 2 b/screenshots/test copy 3/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 20 b/screenshots/test copy 3/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 21 b/screenshots/test copy 3/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 22 b/screenshots/test copy 3/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 23 b/screenshots/test copy 3/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 24 b/screenshots/test copy 3/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 25 b/screenshots/test copy 3/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 26 b/screenshots/test copy 3/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 27 b/screenshots/test copy 3/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 28 b/screenshots/test copy 3/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 29 b/screenshots/test copy 3/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 3 b/screenshots/test copy 3/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 30 b/screenshots/test copy 3/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 31 b/screenshots/test copy 3/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 32 b/screenshots/test copy 3/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 33 b/screenshots/test copy 3/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 34 b/screenshots/test copy 3/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 35 b/screenshots/test copy 3/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 4 b/screenshots/test copy 3/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 5 b/screenshots/test copy 3/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 6 b/screenshots/test copy 3/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 7 b/screenshots/test copy 3/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 8 b/screenshots/test copy 3/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 3/1 copy 9 b/screenshots/test copy 3/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 b/screenshots/test copy 4/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy b/screenshots/test copy 4/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 10 b/screenshots/test copy 4/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 11 b/screenshots/test copy 4/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 12 b/screenshots/test copy 4/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 13 b/screenshots/test copy 4/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 14 b/screenshots/test copy 4/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 15 b/screenshots/test copy 4/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 16 b/screenshots/test copy 4/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 17 b/screenshots/test copy 4/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 18 b/screenshots/test copy 4/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 19 b/screenshots/test copy 4/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 2 b/screenshots/test copy 4/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 20 b/screenshots/test copy 4/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 21 b/screenshots/test copy 4/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 22 b/screenshots/test copy 4/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 23 b/screenshots/test copy 4/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 24 b/screenshots/test copy 4/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 25 b/screenshots/test copy 4/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 26 b/screenshots/test copy 4/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 27 b/screenshots/test copy 4/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 28 b/screenshots/test copy 4/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 29 b/screenshots/test copy 4/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 3 b/screenshots/test copy 4/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 30 b/screenshots/test copy 4/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 31 b/screenshots/test copy 4/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 32 b/screenshots/test copy 4/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 33 b/screenshots/test copy 4/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 34 b/screenshots/test copy 4/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 35 b/screenshots/test copy 4/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 4 b/screenshots/test copy 4/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 5 b/screenshots/test copy 4/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 6 b/screenshots/test copy 4/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 7 b/screenshots/test copy 4/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 8 b/screenshots/test copy 4/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 4/1 copy 9 b/screenshots/test copy 4/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 b/screenshots/test copy 5/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy b/screenshots/test copy 5/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 10 b/screenshots/test copy 5/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 11 b/screenshots/test copy 5/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 12 b/screenshots/test copy 5/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 13 b/screenshots/test copy 5/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 14 b/screenshots/test copy 5/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 15 b/screenshots/test copy 5/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 16 b/screenshots/test copy 5/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 17 b/screenshots/test copy 5/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 18 b/screenshots/test copy 5/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 19 b/screenshots/test copy 5/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 2 b/screenshots/test copy 5/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 20 b/screenshots/test copy 5/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 21 b/screenshots/test copy 5/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 22 b/screenshots/test copy 5/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 23 b/screenshots/test copy 5/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 24 b/screenshots/test copy 5/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 25 b/screenshots/test copy 5/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 26 b/screenshots/test copy 5/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 27 b/screenshots/test copy 5/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 28 b/screenshots/test copy 5/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 29 b/screenshots/test copy 5/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 3 b/screenshots/test copy 5/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 30 b/screenshots/test copy 5/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 31 b/screenshots/test copy 5/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 32 b/screenshots/test copy 5/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 33 b/screenshots/test copy 5/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 34 b/screenshots/test copy 5/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 35 b/screenshots/test copy 5/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 4 b/screenshots/test copy 5/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 5 b/screenshots/test copy 5/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 6 b/screenshots/test copy 5/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 7 b/screenshots/test copy 5/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 8 b/screenshots/test copy 5/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy 5/1 copy 9 b/screenshots/test copy 5/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 b/screenshots/test copy/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy b/screenshots/test copy/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 10 b/screenshots/test copy/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 11 b/screenshots/test copy/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 12 b/screenshots/test copy/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 13 b/screenshots/test copy/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 14 b/screenshots/test copy/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 15 b/screenshots/test copy/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 16 b/screenshots/test copy/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 17 b/screenshots/test copy/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 18 b/screenshots/test copy/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 19 b/screenshots/test copy/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 2 b/screenshots/test copy/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 20 b/screenshots/test copy/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 21 b/screenshots/test copy/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 22 b/screenshots/test copy/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 23 b/screenshots/test copy/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 24 b/screenshots/test copy/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 25 b/screenshots/test copy/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 26 b/screenshots/test copy/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 27 b/screenshots/test copy/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 28 b/screenshots/test copy/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 29 b/screenshots/test copy/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 3 b/screenshots/test copy/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 30 b/screenshots/test copy/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 31 b/screenshots/test copy/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 32 b/screenshots/test copy/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 33 b/screenshots/test copy/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 34 b/screenshots/test copy/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 35 b/screenshots/test copy/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 4 b/screenshots/test copy/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 5 b/screenshots/test copy/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 6 b/screenshots/test copy/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 7 b/screenshots/test copy/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 8 b/screenshots/test copy/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/1 copy 9 b/screenshots/test copy/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 b/screenshots/test copy/test/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy b/screenshots/test copy/test/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 10 b/screenshots/test copy/test/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 11 b/screenshots/test copy/test/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 12 b/screenshots/test copy/test/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 13 b/screenshots/test copy/test/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 14 b/screenshots/test copy/test/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 15 b/screenshots/test copy/test/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 16 b/screenshots/test copy/test/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 17 b/screenshots/test copy/test/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 18 b/screenshots/test copy/test/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 19 b/screenshots/test copy/test/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 2 b/screenshots/test copy/test/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 20 b/screenshots/test copy/test/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 21 b/screenshots/test copy/test/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 22 b/screenshots/test copy/test/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 23 b/screenshots/test copy/test/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 24 b/screenshots/test copy/test/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 25 b/screenshots/test copy/test/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 26 b/screenshots/test copy/test/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 27 b/screenshots/test copy/test/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 28 b/screenshots/test copy/test/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 29 b/screenshots/test copy/test/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 3 b/screenshots/test copy/test/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 30 b/screenshots/test copy/test/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 31 b/screenshots/test copy/test/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 32 b/screenshots/test copy/test/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 33 b/screenshots/test copy/test/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 34 b/screenshots/test copy/test/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 35 b/screenshots/test copy/test/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 4 b/screenshots/test copy/test/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 5 b/screenshots/test copy/test/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 6 b/screenshots/test copy/test/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 7 b/screenshots/test copy/test/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 8 b/screenshots/test copy/test/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test copy/test/1 copy 9 b/screenshots/test copy/test/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 b/screenshots/test/1 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy b/screenshots/test/1 copy new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 10 b/screenshots/test/1 copy 10 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 11 b/screenshots/test/1 copy 11 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 12 b/screenshots/test/1 copy 12 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 13 b/screenshots/test/1 copy 13 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 14 b/screenshots/test/1 copy 14 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 15 b/screenshots/test/1 copy 15 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 16 b/screenshots/test/1 copy 16 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 17 b/screenshots/test/1 copy 17 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 18 b/screenshots/test/1 copy 18 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 19 b/screenshots/test/1 copy 19 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 2 b/screenshots/test/1 copy 2 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 20 b/screenshots/test/1 copy 20 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 21 b/screenshots/test/1 copy 21 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 22 b/screenshots/test/1 copy 22 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 23 b/screenshots/test/1 copy 23 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 24 b/screenshots/test/1 copy 24 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 25 b/screenshots/test/1 copy 25 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 26 b/screenshots/test/1 copy 26 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 27 b/screenshots/test/1 copy 27 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 28 b/screenshots/test/1 copy 28 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 29 b/screenshots/test/1 copy 29 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 3 b/screenshots/test/1 copy 3 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 30 b/screenshots/test/1 copy 30 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 31 b/screenshots/test/1 copy 31 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 32 b/screenshots/test/1 copy 32 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 33 b/screenshots/test/1 copy 33 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 34 b/screenshots/test/1 copy 34 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 35 b/screenshots/test/1 copy 35 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 4 b/screenshots/test/1 copy 4 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 5 b/screenshots/test/1 copy 5 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 6 b/screenshots/test/1 copy 6 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 7 b/screenshots/test/1 copy 7 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 8 b/screenshots/test/1 copy 8 new file mode 100644 index 00000000..e69de29b diff --git a/screenshots/test/1 copy 9 b/screenshots/test/1 copy 9 new file mode 100644 index 00000000..e69de29b diff --git a/src/main.ts b/src/main.ts index 421bdffb..95b221ec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -128,6 +128,7 @@ export async function run(): Promise { const terraformChangedModules = getTerraformChangedModules(terraformModules); const terraformModuleNamesToRemove = getTerraformModulesToRemove(allTags, terraformModules); + if (!context.isPrMergeEvent) { await handleReleasePlanComment(config, terraformChangedModules, terraformModuleNamesToRemove); } else { @@ -185,7 +186,7 @@ export async function run(): Promise { setOutput('changed-modules-map', changedModulesMap); setOutput('all-module-names', allModuleNames); setOutput('all-module-paths', allModulePaths); - setOutput('all-modules-map', allModulesMap); + setOutput('all-modules-map', allModulesMap); } catch (error) { if (error instanceof Error) { setFailed(error.message); diff --git a/tf-modules2/s3-bucket-object copy 10/README.md b/tf-modules2/s3-bucket-object copy 10/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 10/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 10/main.tf b/tf-modules2/s3-bucket-object copy 10/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 10/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 10/outputs.tf b/tf-modules2/s3-bucket-object copy 10/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 10/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 10/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 10/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 10/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 10/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 10/variables.tf b/tf-modules2/s3-bucket-object copy 10/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 10/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 10/versions.tf b/tf-modules2/s3-bucket-object copy 10/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 10/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 11/README.md b/tf-modules2/s3-bucket-object copy 11/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 11/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 11/main.tf b/tf-modules2/s3-bucket-object copy 11/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 11/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 11/outputs.tf b/tf-modules2/s3-bucket-object copy 11/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 11/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 11/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 11/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 11/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 11/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 11/variables.tf b/tf-modules2/s3-bucket-object copy 11/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 11/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 11/versions.tf b/tf-modules2/s3-bucket-object copy 11/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 11/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 12/README.md b/tf-modules2/s3-bucket-object copy 12/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 12/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 12/main.tf b/tf-modules2/s3-bucket-object copy 12/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 12/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 12/outputs.tf b/tf-modules2/s3-bucket-object copy 12/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 12/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 12/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 12/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 12/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 12/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 12/variables.tf b/tf-modules2/s3-bucket-object copy 12/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 12/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 12/versions.tf b/tf-modules2/s3-bucket-object copy 12/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 12/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 13/README.md b/tf-modules2/s3-bucket-object copy 13/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 13/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 13/main.tf b/tf-modules2/s3-bucket-object copy 13/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 13/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 13/outputs.tf b/tf-modules2/s3-bucket-object copy 13/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 13/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 13/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 13/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 13/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 13/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 13/variables.tf b/tf-modules2/s3-bucket-object copy 13/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 13/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 13/versions.tf b/tf-modules2/s3-bucket-object copy 13/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 13/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 14/README.md b/tf-modules2/s3-bucket-object copy 14/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 14/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 14/main.tf b/tf-modules2/s3-bucket-object copy 14/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 14/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 14/outputs.tf b/tf-modules2/s3-bucket-object copy 14/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 14/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 14/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 14/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 14/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 14/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 14/variables.tf b/tf-modules2/s3-bucket-object copy 14/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 14/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 14/versions.tf b/tf-modules2/s3-bucket-object copy 14/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 14/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 15/README.md b/tf-modules2/s3-bucket-object copy 15/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 15/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 15/main.tf b/tf-modules2/s3-bucket-object copy 15/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 15/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 15/outputs.tf b/tf-modules2/s3-bucket-object copy 15/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 15/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 15/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 15/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 15/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 15/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 15/variables.tf b/tf-modules2/s3-bucket-object copy 15/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 15/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 15/versions.tf b/tf-modules2/s3-bucket-object copy 15/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 15/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 16/README.md b/tf-modules2/s3-bucket-object copy 16/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 16/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 16/main.tf b/tf-modules2/s3-bucket-object copy 16/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 16/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 16/outputs.tf b/tf-modules2/s3-bucket-object copy 16/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 16/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 16/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 16/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 16/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 16/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 16/variables.tf b/tf-modules2/s3-bucket-object copy 16/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 16/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 16/versions.tf b/tf-modules2/s3-bucket-object copy 16/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 16/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 17/README.md b/tf-modules2/s3-bucket-object copy 17/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 17/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 17/main.tf b/tf-modules2/s3-bucket-object copy 17/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 17/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 17/outputs.tf b/tf-modules2/s3-bucket-object copy 17/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 17/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 17/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 17/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 17/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 17/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 17/variables.tf b/tf-modules2/s3-bucket-object copy 17/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 17/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 17/versions.tf b/tf-modules2/s3-bucket-object copy 17/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 17/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 18/README.md b/tf-modules2/s3-bucket-object copy 18/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 18/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 18/main.tf b/tf-modules2/s3-bucket-object copy 18/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 18/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 18/outputs.tf b/tf-modules2/s3-bucket-object copy 18/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 18/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 18/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 18/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 18/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 18/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 18/variables.tf b/tf-modules2/s3-bucket-object copy 18/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 18/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 18/versions.tf b/tf-modules2/s3-bucket-object copy 18/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 18/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 19/README.md b/tf-modules2/s3-bucket-object copy 19/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 19/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 19/main.tf b/tf-modules2/s3-bucket-object copy 19/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 19/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 19/outputs.tf b/tf-modules2/s3-bucket-object copy 19/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 19/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 19/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 19/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 19/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 19/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 19/variables.tf b/tf-modules2/s3-bucket-object copy 19/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 19/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 19/versions.tf b/tf-modules2/s3-bucket-object copy 19/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 19/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 2/README.md b/tf-modules2/s3-bucket-object copy 2/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 2/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 2/main.tf b/tf-modules2/s3-bucket-object copy 2/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 2/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 2/outputs.tf b/tf-modules2/s3-bucket-object copy 2/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 2/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 2/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 2/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 2/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 2/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 2/variables.tf b/tf-modules2/s3-bucket-object copy 2/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 2/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 2/versions.tf b/tf-modules2/s3-bucket-object copy 2/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 2/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 20/README.md b/tf-modules2/s3-bucket-object copy 20/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 20/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 20/main.tf b/tf-modules2/s3-bucket-object copy 20/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 20/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 20/outputs.tf b/tf-modules2/s3-bucket-object copy 20/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 20/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 20/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 20/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 20/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 20/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 20/variables.tf b/tf-modules2/s3-bucket-object copy 20/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 20/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 20/versions.tf b/tf-modules2/s3-bucket-object copy 20/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 20/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 21/README.md b/tf-modules2/s3-bucket-object copy 21/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 21/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 21/main.tf b/tf-modules2/s3-bucket-object copy 21/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 21/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 21/outputs.tf b/tf-modules2/s3-bucket-object copy 21/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 21/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 21/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 21/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 21/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 21/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 21/variables.tf b/tf-modules2/s3-bucket-object copy 21/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 21/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 21/versions.tf b/tf-modules2/s3-bucket-object copy 21/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 21/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 22/README.md b/tf-modules2/s3-bucket-object copy 22/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 22/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 22/main.tf b/tf-modules2/s3-bucket-object copy 22/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 22/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 22/outputs.tf b/tf-modules2/s3-bucket-object copy 22/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 22/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 22/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 22/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 22/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 22/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 22/variables.tf b/tf-modules2/s3-bucket-object copy 22/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 22/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 22/versions.tf b/tf-modules2/s3-bucket-object copy 22/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 22/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 23/README.md b/tf-modules2/s3-bucket-object copy 23/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 23/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 23/main.tf b/tf-modules2/s3-bucket-object copy 23/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 23/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 23/outputs.tf b/tf-modules2/s3-bucket-object copy 23/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 23/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 23/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 23/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 23/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 23/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 23/variables.tf b/tf-modules2/s3-bucket-object copy 23/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 23/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 23/versions.tf b/tf-modules2/s3-bucket-object copy 23/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 23/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 24/README.md b/tf-modules2/s3-bucket-object copy 24/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 24/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 24/main.tf b/tf-modules2/s3-bucket-object copy 24/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 24/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 24/outputs.tf b/tf-modules2/s3-bucket-object copy 24/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 24/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 24/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 24/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 24/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 24/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 24/variables.tf b/tf-modules2/s3-bucket-object copy 24/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 24/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 24/versions.tf b/tf-modules2/s3-bucket-object copy 24/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 24/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 25/README.md b/tf-modules2/s3-bucket-object copy 25/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 25/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 25/main.tf b/tf-modules2/s3-bucket-object copy 25/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 25/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 25/outputs.tf b/tf-modules2/s3-bucket-object copy 25/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 25/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 25/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 25/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 25/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 25/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 25/variables.tf b/tf-modules2/s3-bucket-object copy 25/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 25/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 25/versions.tf b/tf-modules2/s3-bucket-object copy 25/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 25/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 26/README.md b/tf-modules2/s3-bucket-object copy 26/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 26/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 26/main.tf b/tf-modules2/s3-bucket-object copy 26/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 26/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 26/outputs.tf b/tf-modules2/s3-bucket-object copy 26/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 26/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 26/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 26/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 26/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 26/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 26/variables.tf b/tf-modules2/s3-bucket-object copy 26/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 26/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 26/versions.tf b/tf-modules2/s3-bucket-object copy 26/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 26/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 27/README.md b/tf-modules2/s3-bucket-object copy 27/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 27/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 27/main.tf b/tf-modules2/s3-bucket-object copy 27/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 27/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 27/outputs.tf b/tf-modules2/s3-bucket-object copy 27/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 27/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 27/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 27/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 27/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 27/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 27/variables.tf b/tf-modules2/s3-bucket-object copy 27/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 27/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 27/versions.tf b/tf-modules2/s3-bucket-object copy 27/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 27/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 28/README.md b/tf-modules2/s3-bucket-object copy 28/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 28/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 28/main.tf b/tf-modules2/s3-bucket-object copy 28/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 28/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 28/outputs.tf b/tf-modules2/s3-bucket-object copy 28/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 28/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 28/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 28/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 28/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 28/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 28/variables.tf b/tf-modules2/s3-bucket-object copy 28/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 28/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 28/versions.tf b/tf-modules2/s3-bucket-object copy 28/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 28/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 29/README.md b/tf-modules2/s3-bucket-object copy 29/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 29/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 29/main.tf b/tf-modules2/s3-bucket-object copy 29/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 29/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 29/outputs.tf b/tf-modules2/s3-bucket-object copy 29/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 29/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 29/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 29/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 29/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 29/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 29/variables.tf b/tf-modules2/s3-bucket-object copy 29/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 29/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 29/versions.tf b/tf-modules2/s3-bucket-object copy 29/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 29/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 3/README.md b/tf-modules2/s3-bucket-object copy 3/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 3/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 3/main.tf b/tf-modules2/s3-bucket-object copy 3/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 3/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 3/outputs.tf b/tf-modules2/s3-bucket-object copy 3/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 3/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 3/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 3/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 3/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 3/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 3/variables.tf b/tf-modules2/s3-bucket-object copy 3/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 3/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 3/versions.tf b/tf-modules2/s3-bucket-object copy 3/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 3/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 30/README.md b/tf-modules2/s3-bucket-object copy 30/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 30/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 30/main.tf b/tf-modules2/s3-bucket-object copy 30/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 30/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 30/outputs.tf b/tf-modules2/s3-bucket-object copy 30/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 30/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 30/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 30/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 30/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 30/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 30/variables.tf b/tf-modules2/s3-bucket-object copy 30/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 30/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 30/versions.tf b/tf-modules2/s3-bucket-object copy 30/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 30/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 31/README.md b/tf-modules2/s3-bucket-object copy 31/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 31/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 31/main.tf b/tf-modules2/s3-bucket-object copy 31/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 31/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 31/outputs.tf b/tf-modules2/s3-bucket-object copy 31/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 31/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 31/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 31/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 31/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 31/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 31/variables.tf b/tf-modules2/s3-bucket-object copy 31/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 31/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 31/versions.tf b/tf-modules2/s3-bucket-object copy 31/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 31/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 32/README.md b/tf-modules2/s3-bucket-object copy 32/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 32/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 32/main.tf b/tf-modules2/s3-bucket-object copy 32/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 32/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 32/outputs.tf b/tf-modules2/s3-bucket-object copy 32/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 32/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 32/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 32/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 32/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 32/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 32/variables.tf b/tf-modules2/s3-bucket-object copy 32/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 32/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 32/versions.tf b/tf-modules2/s3-bucket-object copy 32/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 32/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 4/README.md b/tf-modules2/s3-bucket-object copy 4/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 4/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 4/main.tf b/tf-modules2/s3-bucket-object copy 4/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 4/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 4/outputs.tf b/tf-modules2/s3-bucket-object copy 4/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 4/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 4/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 4/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 4/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 4/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 4/variables.tf b/tf-modules2/s3-bucket-object copy 4/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 4/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 4/versions.tf b/tf-modules2/s3-bucket-object copy 4/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 4/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 5/README.md b/tf-modules2/s3-bucket-object copy 5/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 5/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 5/main.tf b/tf-modules2/s3-bucket-object copy 5/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 5/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 5/outputs.tf b/tf-modules2/s3-bucket-object copy 5/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 5/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 5/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 5/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 5/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 5/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 5/variables.tf b/tf-modules2/s3-bucket-object copy 5/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 5/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 5/versions.tf b/tf-modules2/s3-bucket-object copy 5/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 5/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 6/README.md b/tf-modules2/s3-bucket-object copy 6/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 6/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 6/main.tf b/tf-modules2/s3-bucket-object copy 6/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 6/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 6/outputs.tf b/tf-modules2/s3-bucket-object copy 6/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 6/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 6/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 6/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 6/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 6/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 6/variables.tf b/tf-modules2/s3-bucket-object copy 6/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 6/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 6/versions.tf b/tf-modules2/s3-bucket-object copy 6/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 6/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 7/README.md b/tf-modules2/s3-bucket-object copy 7/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 7/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 7/main.tf b/tf-modules2/s3-bucket-object copy 7/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 7/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 7/outputs.tf b/tf-modules2/s3-bucket-object copy 7/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 7/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 7/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 7/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 7/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 7/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 7/variables.tf b/tf-modules2/s3-bucket-object copy 7/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 7/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 7/versions.tf b/tf-modules2/s3-bucket-object copy 7/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 7/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 8/README.md b/tf-modules2/s3-bucket-object copy 8/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 8/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 8/main.tf b/tf-modules2/s3-bucket-object copy 8/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 8/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 8/outputs.tf b/tf-modules2/s3-bucket-object copy 8/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 8/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 8/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 8/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 8/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 8/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 8/variables.tf b/tf-modules2/s3-bucket-object copy 8/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 8/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 8/versions.tf b/tf-modules2/s3-bucket-object copy 8/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 8/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy 9/README.md b/tf-modules2/s3-bucket-object copy 9/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 9/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy 9/main.tf b/tf-modules2/s3-bucket-object copy 9/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 9/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy 9/outputs.tf b/tf-modules2/s3-bucket-object copy 9/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 9/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy 9/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy 9/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 9/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy 9/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy 9/variables.tf b/tf-modules2/s3-bucket-object copy 9/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 9/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy 9/versions.tf b/tf-modules2/s3-bucket-object copy 9/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy 9/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object copy/README.md b/tf-modules2/s3-bucket-object copy/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object copy/main.tf b/tf-modules2/s3-bucket-object copy/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object copy/outputs.tf b/tf-modules2/s3-bucket-object copy/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object copy/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object copy/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object copy/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object copy/variables.tf b/tf-modules2/s3-bucket-object copy/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object copy/versions.tf b/tf-modules2/s3-bucket-object copy/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object copy/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +} diff --git a/tf-modules2/s3-bucket-object/README.md b/tf-modules2/s3-bucket-object/README.md new file mode 100644 index 00000000..6f4f56d6 --- /dev/null +++ b/tf-modules2/s3-bucket-object/README.md @@ -0,0 +1,5 @@ +# AWS S3 Bucket Object Terraform Example Module + +Creates S3 bucket objects with different configurations. + +## Usage diff --git a/tf-modules2/s3-bucket-object/main.tf b/tf-modules2/s3-bucket-object/main.tf new file mode 100644 index 00000000..cc8ae6d2 --- /dev/null +++ b/tf-modules2/s3-bucket-object/main.tf @@ -0,0 +1,49 @@ +resource "aws_s3_object" "this" { + count = var.create ? 1 : 0 + + bucket = var.bucket + key = var.key + force_destroy = var.force_destroy + + acl = var.acl + storage_class = try(upper(var.storage_class), var.storage_class) + + source = var.file_source + content = var.content + content_base64 = var.content_base64 + etag = var.etag + + cache_control = var.cache_control + content_disposition = var.content_disposition + content_encoding = var.content_encoding + content_language = var.content_language + content_type = var.content_type + website_redirect = var.website_redirect + metadata = var.metadata + + server_side_encryption = var.server_side_encryption + kms_key_id = var.kms_key_id + bucket_key_enabled = var.bucket_key_enabled + + object_lock_legal_hold_status = try(tobool(var.object_lock_legal_hold_status) ? "ON" : upper(var.object_lock_legal_hold_status), var.object_lock_legal_hold_status) + object_lock_mode = try(upper(var.object_lock_mode), var.object_lock_mode) + object_lock_retain_until_date = var.object_lock_retain_until_date + + source_hash = var.source_hash + + tags = var.tags + + dynamic "override_provider" { + for_each = var.override_default_tags ? [true] : [] + + content { + default_tags { + tags = {} + } + } + } + + lifecycle { + ignore_changes = [object_lock_retain_until_date] + } +} diff --git a/tf-modules2/s3-bucket-object/outputs.tf b/tf-modules2/s3-bucket-object/outputs.tf new file mode 100644 index 00000000..5cdb1db4 --- /dev/null +++ b/tf-modules2/s3-bucket-object/outputs.tf @@ -0,0 +1,14 @@ +output "s3_object_id" { + description = "The key of S3 object" + value = try(aws_s3_object.this[0].id, "") +} + +output "s3_object_etag" { + description = "The ETag generated for the object (an MD5 sum of the object content)." + value = try(aws_s3_object.this[0].etag, "") +} + +output "s3_object_version_id" { + description = "A unique version ID value for the object, if bucket versioning is enabled." + value = try(aws_s3_object.this[0].version_id, "") +} diff --git a/tf-modules2/s3-bucket-object/tests/default.tftest.hcl b/tf-modules2/s3-bucket-object/tests/default.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object/tests/sub/main.tftest.hcl b/tf-modules2/s3-bucket-object/tests/sub/main.tftest.hcl new file mode 100644 index 00000000..e69de29b diff --git a/tf-modules2/s3-bucket-object/variables.tf b/tf-modules2/s3-bucket-object/variables.tf new file mode 100644 index 00000000..44d12735 --- /dev/null +++ b/tf-modules2/s3-bucket-object/variables.tf @@ -0,0 +1,155 @@ +variable "create" { + description = "Whether to create this resource or not?" + type = bool + default = true +} + +variable "bucket" { + description = "The name of the bucket to put the file in. Alternatively, an S3 access point ARN can be specified." + type = string + default = "" +} + +variable "key" { + description = "The name of the object once it is in the bucket." + type = string + default = "" +} + +variable "file_source" { + description = "The path to a file that will be read and uploaded as raw bytes for the object content." + type = string + default = null +} + +variable "content" { + description = "Literal string value to use as the object content, which will be uploaded as UTF-8-encoded text." + type = string + default = null +} + +variable "content_base64" { + description = "Base64-encoded data that will be decoded and uploaded as raw bytes for the object content. This allows safely uploading non-UTF8 binary data, but is recommended only for small content such as the result of the gzipbase64 function with small text strings. For larger objects, use source to stream the content from a disk file." + type = string + default = null +} + +variable "acl" { + description = "The canned ACL to apply. Valid values are private, public-read, public-read-write, aws-exec-read, authenticated-read, bucket-owner-read, and bucket-owner-full-control. Defaults to private." + type = string + default = null +} + +variable "cache_control" { + description = "Specifies caching behavior along the request/reply chain." + type = string # map? + default = null +} + +variable "content_disposition" { + description = "Specifies presentational information for the object." + type = string # map? + default = null +} + +variable "content_encoding" { + description = "Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type referenced by the Content-Type header field." + type = string + default = null +} + +variable "content_language" { + description = "The language the content is in e.g. en-US or en-GB." + type = string + default = null +} + +variable "content_type" { + description = "A standard MIME type describing the format of the object data, e.g. application/octet-stream. All Valid MIME Types are valid for this input." + type = string + default = null +} + +variable "website_redirect" { + description = "Specifies a target URL for website redirect." + type = string + default = null +} + +variable "storage_class" { + description = "Specifies the desired Storage Class for the object. Can be either STANDARD, REDUCED_REDUNDANCY, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE, or STANDARD_IA. Defaults to STANDARD." + type = string + default = null +} + +variable "etag" { + description = "Used to trigger updates. This attribute is not compatible with KMS encryption, kms_key_id or server_side_encryption = \"aws:kms\"." + type = string + default = null +} + +variable "server_side_encryption" { + description = "Specifies server-side encryption of the object in S3. Valid values are \"AES256\" and \"aws:kms\"." + type = string + default = null +} + +variable "kms_key_id" { + description = "Amazon Resource Name (ARN) of the KMS Key to use for object encryption. If the S3 Bucket has server-side encryption enabled, that value will automatically be used. If referencing the aws_kms_key resource, use the arn attribute. If referencing the aws_kms_alias data source or resource, use the target_key_arn attribute. Terraform will only perform drift detection if a configuration value is provided." + type = string + default = null +} + +variable "bucket_key_enabled" { + description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS." + type = bool + default = null +} + +variable "metadata" { + description = "A map of keys/values to provision metadata (will be automatically prefixed by x-amz-meta-, note that only lowercase label are currently supported by the AWS Go API)." + type = map(string) + default = {} +} + +variable "tags" { + description = "A map of tags to assign to the object." + type = map(string) + default = {} +} + +variable "force_destroy" { + description = "Allow the object to be deleted by removing any legal hold on any object version. Default is false. This value should be set to true only if the bucket has S3 object lock enabled." + type = bool + default = false +} + +variable "object_lock_legal_hold_status" { + description = "The legal hold status that you want to apply to the specified object. Valid values are ON and OFF." + type = string + default = null +} + +variable "object_lock_mode" { + description = "The object lock retention mode that you want to apply to this object. Valid values are GOVERNANCE and COMPLIANCE." + type = string + default = null +} + +variable "object_lock_retain_until_date" { + description = "The date and time, in RFC3339 format, when this object's object lock will expire." + type = string + default = null +} + +variable "source_hash" { + description = "Triggers updates like etag but useful to address etag encryption limitations. Set using filemd5(\"path/to/source\") (Terraform 0.11.12 or later). (The value is only stored in state and not saved by AWS.)" + type = string + default = null +} + +variable "override_default_tags" { + description = "Ignore provider default_tags. S3 objects support a maximum of 10 tags." + type = bool + default = false +} diff --git a/tf-modules2/s3-bucket-object/versions.tf b/tf-modules2/s3-bucket-object/versions.tf new file mode 100644 index 00000000..a9c2eed5 --- /dev/null +++ b/tf-modules2/s3-bucket-object/versions.tf @@ -0,0 +1,10 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + aws = { + source = "hashicorp/aws" + version = ">= 5.24" + } + } +}