This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
forked from dtan4/terraforming
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Mirkhaydarov
committed
Jul 7, 2019
1 parent
0799641
commit e5556b6
Showing
2 changed files
with
247 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,116 @@ | ||
<% buckets.each do |bucket| -%> | ||
|
||
resource "aws_s3_bucket" "<%= module_name_of(bucket) %>" { | ||
bucket = "<%= bucket.name %>" | ||
acl = "private" | ||
region = "<%=region(bucket)%>" | ||
<%- unless (policy = bucket_policy_of(bucket)).nil? -%> | ||
<%- unless (policy = bucket_policy_of(bucket)).nil? -%> | ||
policy = <<POLICY | ||
<%= prettify_policy(policy) %> | ||
POLICY | ||
<%- end -%> | ||
<%- end -%> | ||
|
||
<%- if tagging?(bucket)-%> | ||
<%- if tagging?(bucket) -%> | ||
tags { | ||
<% bucket.tagging.tag_set.each do |t| -%> | ||
"<%=t[:key]%>" = "<%=t[:value]%>" | ||
<%end-%> | ||
} | ||
<%- end -%> | ||
|
||
<%- if cors?(bucket) -%> | ||
<%- bucket.tagging.tag_set.each do |tag| -%> | ||
<%= tag[:key] %> = "<%= tag[:value] %>" | ||
<%- end -%> | ||
} | ||
<%- end -%> | ||
|
||
<% bucket.cors.cors_rules.each do |rule| -%> | ||
cors_rule { | ||
allowed_methods = <%=rule.allowed_methods%> | ||
allowed_origins = <%=rule.allowed_origins%> | ||
<%unless rule.allowed_headers.nil? %> | ||
allowed_headers = <%=rule.allowed_headers%> | ||
<%end%> | ||
<%unless rule.expose_headers.nil? %> | ||
expose_headers = <%=rule.expose_headers%> | ||
<%end%> | ||
<%unless rule.max_age_seconds.nil? %> | ||
max_age_seconds = <%=rule.max_age_seconds%> | ||
<%end%> | ||
<%- if cors?(bucket) -%> | ||
<%- bucket.cors.cors_rules.each do |rule| -%> | ||
cors_rule { | ||
allowed_methods = <%= rule.allowed_methods %> | ||
allowed_origins = <%= rule.allowed_origins %> | ||
<%- unless rule.allowed_headers.nil? -%> | ||
allowed_headers = <%= rule.allowed_headers %> | ||
<%- end -%> | ||
<%- unless rule.expose_headers.nil? -%> | ||
expose_headers = <%= rule.expose_headers %> | ||
<%- end -%> | ||
<%- unless rule.max_age_seconds.nil? -%> | ||
max_age_seconds = <%= rule.max_age_seconds %> | ||
<%- end -%> | ||
} | ||
<%end-%> | ||
<%- end -%> | ||
<%- end -%> | ||
<%- end -%> | ||
|
||
<%- unless bucket.versioning.status.nil? -%> | ||
<%- unless bucket.versioning.status.nil? -%> | ||
versioning { | ||
enabled = <%=bucket.versioning.status == 'Enabled'%> | ||
enabled = <%= bucket.versioning.status == 'Enabled' %> | ||
} | ||
<%- end -%> | ||
<%- end -%> | ||
|
||
<%- unless bucket.logging.logging_enabled.nil? -%> | ||
<%- unless bucket.logging.logging_enabled.nil? -%> | ||
logging { | ||
target_bucket = "<%=bucket.logging.logging_enabled.target_bucket%>" | ||
target_prefix = "<%=bucket.logging.logging_enabled.target_prefix%>" | ||
target_bucket = "<%= bucket.logging.logging_enabled.target_bucket %>" | ||
target_prefix = "<%= bucket.logging.logging_enabled.target_prefix %>" | ||
} | ||
<%- end -%> | ||
<%- end -%> | ||
|
||
<%- if lifecycle?(bucket) -%> | ||
<% bucket.lifecycle_configuration.rules.each do |rule| -%> | ||
lifecycle_rule { | ||
id = "<%=rule.id%>" | ||
enabled = <%=rule.status == 'Enabled'%> | ||
prefix = "<%=rule.prefix%>" | ||
<% rule.transitions.each do |transition| -%> | ||
transition { | ||
storage_class = "<%=transition.storage_class%>" | ||
<%unless transition.days.nil? %> | ||
days = <%=transition.days%> | ||
<%end%> | ||
<%unless transition.date.nil? %> | ||
date = "<%=transition.date%>" | ||
<%end%> | ||
} | ||
<%end-%> | ||
<%unless rule.expiration.nil? %> | ||
expiration { | ||
<%unless rule.expiration.days.nil? %> | ||
days = <%=rule.expiration.days%> | ||
<%end%> | ||
<%unless rule.expiration.date.nil? %> | ||
date = "<%=rule.expiration.date%>" | ||
<%end%> | ||
<%unless rule.expiration.expired_object_delete_marker.nil? %> | ||
expired_object_delete_marker = "<%=rule.expiration.expired_object_delete_marker%>" | ||
<%end%> | ||
} | ||
<%end%> | ||
<% rule.noncurrent_version_transitions.each do |transition| -%> | ||
noncurrent_version_transition { | ||
days = <%=transition.noncurrent_days%> | ||
storage_class = "<%=transition.storage_class%>" | ||
} | ||
<%end-%> | ||
<%unless rule.noncurrent_version_expiration.nil? %> | ||
noncurrent_version_expiration { | ||
days = <%=rule.noncurrent_version_expiration.noncurrent_days%> | ||
} | ||
<%end%> | ||
<%unless rule.abort_incomplete_multipart_upload.nil? %> | ||
abort_incomplete_multipart_upload_days = <%=rule.abort_incomplete_multipart_upload.days_after_initiation%> | ||
<%end%> | ||
} | ||
<%if website_configuation?(bucket) %> | ||
website { | ||
index_document = "<%=bucket.website.index_document.suffix%>" | ||
<%unless bucket.website.error_document.nil? %> | ||
error_document = "<%=bucket.website.error_document.key%>" | ||
<%end%> | ||
<%unless bucket.website.routing_rules.nil? %> | ||
routing_rules = <<EOF | ||
<%=prettify_website_routing_rules(bucket)%> | ||
EOF | ||
<%end%> | ||
} | ||
<%end%> | ||
<%end-%> | ||
<%- end -%> | ||
} | ||
<%- if lifecycle?(bucket) -%> | ||
<%- bucket.lifecycle_configuration.rules.each do |rule| -%> | ||
lifecycle_rule { | ||
id = "<%= rule.id %>" | ||
prefix = "<%= rule.prefix %>" | ||
enabled = <%= rule.status == 'Enabled' %> | ||
<%- rule.transitions.each do |transition| -%> | ||
transition { | ||
storage_class = "<%= transition.storage_class %>" | ||
<%- unless transition.days.nil? %> | ||
days = <%= transition.days %> | ||
<%- end -%> | ||
<%- unless transition.date.nil? -%> | ||
date = "<%= transition.date %>" | ||
<%- end -%> | ||
} | ||
<%- end -%> | ||
|
||
<%- unless rule.expiration.nil? -%> | ||
expiration { | ||
<%- unless rule.expiration.days.nil? -%> | ||
days = <%= rule.expiration.days %> | ||
<%- end -%> | ||
<%- unless rule.expiration.date.nil? -%> | ||
date = "<%= rule.expiration.date %>" | ||
<%- end -%> | ||
<%- unless rule.expiration.expired_object_delete_marker.nil? -%> | ||
expired_object_delete_marker = "<%= rule.expiration.expired_object_delete_marker %>" | ||
<%- end -%> | ||
} | ||
<%- end -%> | ||
|
||
<%- rule.noncurrent_version_transitions.each do |transition| -%> | ||
noncurrent_version_transition { | ||
days = <%= transition.noncurrent_days %> | ||
storage_class = "<%= transition.storage_class %>" | ||
} | ||
<%- end-%> | ||
|
||
<%- unless rule.noncurrent_version_expiration.nil? -%> | ||
noncurrent_version_expiration { | ||
days = <%= rule.noncurrent_version_expiration.noncurrent_days %> | ||
} | ||
<%- end -%> | ||
|
||
<%- unless rule.abort_incomplete_multipart_upload.nil? -%> | ||
abort_incomplete_multipart_upload_days = <%= rule.abort_incomplete_multipart_upload.days_after_initiation %> | ||
<%- end -%> | ||
} | ||
<%- end %> | ||
<%- end -%> | ||
|
||
<%- if website_configuation?(bucket) %> | ||
website { | ||
index_document = "<%= bucket.website.index_document.suffix %>" | ||
<%- unless bucket.website.error_document.nil? %> | ||
error_document = "<%= bucket.website.error_document.key %>" | ||
<%- end -%> | ||
<%- unless bucket.website.routing_rules.nil? %> | ||
routing_rules = <%= prettify_website_routing_rules(bucket) %> | ||
<%- end -%> | ||
} | ||
<%- end -%> | ||
|
||
<% end -%> | ||
} | ||
<%- end -%> |
Oops, something went wrong.