lib/jets/resource/iam/policy_document.rb in jets-0.8.18 vs lib/jets/resource/iam/policy_document.rb in jets-0.9.0
- old
+ new
@@ -8,27 +8,23 @@
# empty starting policy that will be altered
@policy = {
version: "2012-10-17",
statement: []
}
- # https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_sid.html
- @sid = 0 # counter
end
def policy_document
definitions.map { |definition| standardize(definition) }
Jets::Camelizer.transform(@policy)
end
memoize :policy_document # only process policy_document once
def standardize(definition)
- @sid += 1
case definition
when String
# Expands simple string from: logs => logs:*
definition = "#{definition}:*" unless definition.include?(':')
@policy[:statement] << {
- sid: "Stmt#{@sid}",
action: [definition],
effect: "Allow",
resource: "*",
}
when Hash