3 # Copyright (c) 2021 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 echo "---> terraform_s3_docs_ship.sh"
20 cat >"/w/workspace/main.tf" <<'END_OF_TERRAFORM_SCRIPT'
24 s3_force_path_style = false
25 skip_credentials_validation = true
26 skip_metadata_api_check = true
27 skip_requesting_account_id = true
32 xml = "application/xml",
40 svg = "image/svg+xml",
44 js = "application/javascript",
45 pdf = "application/pdf"
46 json = "application/json",
54 variable "workspace_dir" {
55 description = "Workspace base directory"
59 variable "file_match_pattern" {
60 description = "File matching pattern"
66 description = "S3 bucket name"
68 default = "fdio-docs-s3-cloudfront-index"
71 variable "bucket_path" {
72 description = "S3 bucket path to key"
76 resource "aws_s3_bucket_object" "object" {
77 for_each = fileset(var.workspace_dir, var.file_match_pattern)
80 key = "${var.bucket_path}${each.value}"
81 source = "${var.workspace_dir}/${each.value}"
83 cache_control = "no-store,max-age=0,s-maxage=0"
84 etag = filemd5("${var.workspace_dir}/${each.value}")
85 content_type = lookup(
87 regex("\\.(?P<extension>[A-Za-z0-9]+)$", each.value).extension,
88 "application/octet-stream"
91 END_OF_TERRAFORM_SCRIPT