AWS IAM User Policy

This page shows how to write Terraform and CloudFormation for IAM User Policy and write them securely.

aws_iam_user_policy (Terraform)

The User Policy in IAM can be configured in Terraform with the resource name aws_iam_user_policy. The following sections describe 5 examples of how to use the resource and its parameters.

Example Usage from GitHub

github-iconmortyre/misc
resource "aws_iam_user_policy" "nperevozchikov_EKS-FullAccess" {
  name = "EKS-FullAccess"

  policy = <<POLICY
{
  "Statement": [
github-iconmortyre/misc
resource "aws_iam_user_policy" "nperevozchikov_EKS-FullAccess" {
  name = "EKS-FullAccess"

  policy = <<POLICY
{
  "Statement": [
github-iconstorebot/pr_demo_flat
resource "aws_iam_user_policy" "rootUserNotContainMfaTypeVirtual" {
  name = "test"
  user = "root"

  policy = <<EOF
{
github-iconknagu/terraform-eks-main
resource "aws_iam_user_policy" "vpc_user_policy" {
  name = "vpc-user-policy"
  user = aws_iam_user.vpc.name

  policy = <<EOF
{
github-iconowenbendavies/cms
resource "aws_iam_user_policy" "app_cognito" {
  name   = "cognito"
  policy = data.aws_iam_policy_document.cognito.json
  user   = aws_iam_user.app.name
}

Parameters

Explanation in Terraform Registry

Provides an IAM policy attached to a user.

AWS::IAM::User (CloudFormation)

The User in IAM can be configured in CloudFormation with the resource name AWS::IAM::User. The following sections describe how to use the resource and its parameters.

Parameters

Explanation in CloudFormation Registry

Creates a new IAM user for your AWS account. For information about quotas for the number of IAM users you can create, see IAM and AWS STS quotas in the IAM User Guide.

Frequently asked questions

What is AWS IAM User Policy?

AWS IAM User Policy is a resource for IAM of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS IAM User Policy?

For Terraform, the mortyre/misc, mortyre/misc and storebot/pr_demo_flat source code examples are useful. See the Terraform Example section for further details.

security-icon

Scan your IaC problem in 3 minutes for free

You can keep your IaC security for free. No credit card required.