Skip to contents

Update a policy

Usage

aws_policy_update(arn, document, default = FALSE)

Arguments

arn

(character) policy arn. required

document

(character) the policy document you want to use as the content for the new policy. required

default

(character) set this version as the policy's default version? optional. When this parameter is TRUE, the new policy version becomes the operative version. That is, it becomes the version that is in effect for the IAM users, groups, and roles that the policy is attached to. default: FALSE

Value

a tibble with policy version details:

  • VersionId

  • IsDefaultVersion

  • CreateDate

Examples

if (FALSE) { # aws_has_creds()
if (aws_policy_exists("polisee")) {
  aws_policy_delete("polisee")
}

# Create policy document
st8ment1 <- aws_policy_statement("iam:GetUser", "*")
st8ment2 <- aws_policy_statement("s3:ListAllMyBuckets", "*")
doc <- aws_policy_document_create(st8ment1, st8ment2)

# Create policy
invisible(aws_policy_create("polisee", document = doc))

# Update the same policy
new_doc <- aws_policy_document_create(st8ment1)
arn <- as_policy_arn("polisee", local = TRUE)
aws_policy_update(arn, document = new_doc, default = TRUE)
aws_policy_list_versions("polisee")

# cleanup - delete the policy
aws_policy_delete_version("polisee", "v1")
aws_policy_delete("polisee")
}