aws_policy_delete: Delete a user managed policy

aws_policy_deleteR Documentation

Delete a user managed policy

Description

Delete a user managed policy

Usage

aws_policy_delete(name)

Arguments

name

(character) a policy name. required. within the function we lookup the policy arn which is what's passed to the AWS API

Value

invisibly returns NULL

AWS managed policies

You can not delete AWS managed policies.

Deleting process (adapted from paws docs)

Before you can delete a managed policy, you must first detach the policy from all users, groups, and roles that it is attached to. In addition, you must delete all the policy's versions. The following steps describe the process for deleting a managed policy:

  • Detach the policy from all users, groups, and roles that the policy is attached to using aws_policy_attach(). To list all the users, groups, and roles that a policy is attached to use aws_policy_list_entities()

  • Delete all versions of the policy using aws_policy_delete_version(). To list the policy's versions, use aws_policy_list_versions(). You cannot use aws_policy_delete_version() to delete the version that is marked as the default version. You delete the policy's default version in the next step of the process.

  • Delete the policy using this function (this automatically deletes the policy's default version)

References

delete_policy

See Also

Other policies: as_policy_arn(), aws_policies(), aws_policy(), aws_policy_attach(), aws_policy_create(), aws_policy_delete_version(), aws_policy_detach(), aws_policy_exists(), aws_policy_list_entities(), aws_policy_list_versions(), aws_policy_update()

Examples


if (aws_policy_exists("RdsAllow456")) {
  aws_policy_delete("RdsAllow456")
}

# Create policy document
doc <- aws_policy_document_create(
  aws_policy_statement(
    action = "rds-db:connect",
    resource = "*"
  )
)

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

# Delete policy
aws_policy_delete("RdsAllow456")


sixtyfour documentation built on April 3, 2025, 8:22 p.m.