class GeoEngineer::Resources::AwsIamPolicy

AwsIamPolicy aws_iam_policy terrform resource,

{www.terraform.io/docs/providers/aws/r/iam_policy.html Terraform Docs}

Public Class Methods

_all_remote_policies(provider) click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 47
def self._all_remote_policies(provider)
  AwsClients.iam(provider)
            .list_policies({ scope: "Local" })
            .each.map(&:policies).flatten.map(&:to_h)
end
_fetch_remote_resources(provider) click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 53
def self._fetch_remote_resources(provider)
  _all_remote_policies(provider).map(&:to_h).map do |policy|
    {
      _terraform_id: policy[:arn],
      _geo_id: policy[:policy_name],
      arn: policy[:arn],
      default_version_id: policy[:default_version_id],
      name: policy[:policy_name]
    }
  end
end

Public Instance Methods

_get_policy_document(arn, version_id) click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 41
def _get_policy_document(arn, version_id)
  response = AwsClients.iam.get_policy_version({ policy_arn: arn,
                                                 version_id: version_id })
  URI.decode(response.policy_version.document)
end
_policy_file(path, binding_obj = nil) click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 37
def _policy_file(path, binding_obj = nil)
  _json_file(:policy, path, binding_obj)
end
support_tags?() click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 33
def support_tags?
  false
end
to_terraform_state() click to toggle source
# File lib/geoengineer/resources/aws_iam_policy.rb, line 17
def to_terraform_state
  arn = NullObject.maybe(remote_resource).arn
  default_version_id = NullObject.maybe(remote_resource).default_version_id

  policy = _get_policy_document(arn, default_version_id)

  tfstate = super

  attributes = { 'policy' => policy }
  attributes['arn'] = arn if arn

  tfstate[:primary][:attributes] = attributes

  tfstate
end