published on Tuesday, Mar 31, 2026 by Pulumi
published on Tuesday, Mar 31, 2026 by Pulumi
Resource for maintaining exclusive management of managed IAM policies assigned to an AWS IAM (Identity & Access Management) user.
!> This resource takes exclusive ownership over managed IAM policies attached to a user. This includes removal of managed IAM policies which are not explicitly configured. To prevent persistent drift, ensure any aws.iam.UserPolicyAttachment resources managed alongside this resource are included in the policyArns argument.
Destruction of this resource means Terraform will no longer manage reconciliation of the configured policy attachments. It will not detach the configured policies from the user.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.iam.UserPolicyAttachmentsExclusive("example", {
userName: exampleAwsIamUser.name,
policyArns: [exampleAwsIamPolicy.arn],
});
import pulumi
import pulumi_aws as aws
example = aws.iam.UserPolicyAttachmentsExclusive("example",
user_name=example_aws_iam_user["name"],
policy_arns=[example_aws_iam_policy["arn"]])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := iam.NewUserPolicyAttachmentsExclusive(ctx, "example", &iam.UserPolicyAttachmentsExclusiveArgs{
UserName: pulumi.Any(exampleAwsIamUser.Name),
PolicyArns: pulumi.StringArray{
exampleAwsIamPolicy.Arn,
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Iam.UserPolicyAttachmentsExclusive("example", new()
{
UserName = exampleAwsIamUser.Name,
PolicyArns = new[]
{
exampleAwsIamPolicy.Arn,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.UserPolicyAttachmentsExclusive;
import com.pulumi.aws.iam.UserPolicyAttachmentsExclusiveArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new UserPolicyAttachmentsExclusive("example", UserPolicyAttachmentsExclusiveArgs.builder()
.userName(exampleAwsIamUser.name())
.policyArns(exampleAwsIamPolicy.arn())
.build());
}
}
resources:
example:
type: aws:iam:UserPolicyAttachmentsExclusive
properties:
userName: ${exampleAwsIamUser.name}
policyArns:
- ${exampleAwsIamPolicy.arn}
Disallow Managed IAM Policies
To automatically remove any configured managed IAM policies, set the policyArns argument to an empty list.
This will not prevent managed IAM policies from being assigned to a user via Terraform (or any other interface). This resource enables bringing managed IAM policy assignments into a configured state, however, this reconciliation happens only when
applyis proactively run.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.iam.UserPolicyAttachmentsExclusive("example", {
userName: exampleAwsIamUser.name,
policyArns: [],
});
import pulumi
import pulumi_aws as aws
example = aws.iam.UserPolicyAttachmentsExclusive("example",
user_name=example_aws_iam_user["name"],
policy_arns=[])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := iam.NewUserPolicyAttachmentsExclusive(ctx, "example", &iam.UserPolicyAttachmentsExclusiveArgs{
UserName: pulumi.Any(exampleAwsIamUser.Name),
PolicyArns: pulumi.StringArray{},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Iam.UserPolicyAttachmentsExclusive("example", new()
{
UserName = exampleAwsIamUser.Name,
PolicyArns = new[] {},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.UserPolicyAttachmentsExclusive;
import com.pulumi.aws.iam.UserPolicyAttachmentsExclusiveArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new UserPolicyAttachmentsExclusive("example", UserPolicyAttachmentsExclusiveArgs.builder()
.userName(exampleAwsIamUser.name())
.policyArns()
.build());
}
}
resources:
example:
type: aws:iam:UserPolicyAttachmentsExclusive
properties:
userName: ${exampleAwsIamUser.name}
policyArns: []
Create UserPolicyAttachmentsExclusive Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserPolicyAttachmentsExclusive(name: string, args: UserPolicyAttachmentsExclusiveArgs, opts?: CustomResourceOptions);@overload
def UserPolicyAttachmentsExclusive(resource_name: str,
args: UserPolicyAttachmentsExclusiveArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserPolicyAttachmentsExclusive(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_arns: Optional[Sequence[str]] = None,
user_name: Optional[str] = None)func NewUserPolicyAttachmentsExclusive(ctx *Context, name string, args UserPolicyAttachmentsExclusiveArgs, opts ...ResourceOption) (*UserPolicyAttachmentsExclusive, error)public UserPolicyAttachmentsExclusive(string name, UserPolicyAttachmentsExclusiveArgs args, CustomResourceOptions? opts = null)
public UserPolicyAttachmentsExclusive(String name, UserPolicyAttachmentsExclusiveArgs args)
public UserPolicyAttachmentsExclusive(String name, UserPolicyAttachmentsExclusiveArgs args, CustomResourceOptions options)
type: aws:iam:UserPolicyAttachmentsExclusive
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args UserPolicyAttachmentsExclusiveArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args UserPolicyAttachmentsExclusiveArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args UserPolicyAttachmentsExclusiveArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserPolicyAttachmentsExclusiveArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserPolicyAttachmentsExclusiveArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var userPolicyAttachmentsExclusiveResource = new Aws.Iam.UserPolicyAttachmentsExclusive("userPolicyAttachmentsExclusiveResource", new()
{
PolicyArns = new[]
{
"string",
},
UserName = "string",
});
example, err := iam.NewUserPolicyAttachmentsExclusive(ctx, "userPolicyAttachmentsExclusiveResource", &iam.UserPolicyAttachmentsExclusiveArgs{
PolicyArns: pulumi.StringArray{
pulumi.String("string"),
},
UserName: pulumi.String("string"),
})
var userPolicyAttachmentsExclusiveResource = new UserPolicyAttachmentsExclusive("userPolicyAttachmentsExclusiveResource", UserPolicyAttachmentsExclusiveArgs.builder()
.policyArns("string")
.userName("string")
.build());
user_policy_attachments_exclusive_resource = aws.iam.UserPolicyAttachmentsExclusive("userPolicyAttachmentsExclusiveResource",
policy_arns=["string"],
user_name="string")
const userPolicyAttachmentsExclusiveResource = new aws.iam.UserPolicyAttachmentsExclusive("userPolicyAttachmentsExclusiveResource", {
policyArns: ["string"],
userName: "string",
});
type: aws:iam:UserPolicyAttachmentsExclusive
properties:
policyArns:
- string
userName: string
UserPolicyAttachmentsExclusive Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The UserPolicyAttachmentsExclusive resource accepts the following input properties:
- Policy
Arns List<string> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- Policy
Arns []string - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- policy
Arns List<String> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
- policy
Arns string[] - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name string - IAM user name.
- policy_
arns Sequence[str] - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user_
name str - IAM user name.
- policy
Arns List<String> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserPolicyAttachmentsExclusive resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing UserPolicyAttachmentsExclusive Resource
Get an existing UserPolicyAttachmentsExclusive resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: UserPolicyAttachmentsExclusiveState, opts?: CustomResourceOptions): UserPolicyAttachmentsExclusive@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
policy_arns: Optional[Sequence[str]] = None,
user_name: Optional[str] = None) -> UserPolicyAttachmentsExclusivefunc GetUserPolicyAttachmentsExclusive(ctx *Context, name string, id IDInput, state *UserPolicyAttachmentsExclusiveState, opts ...ResourceOption) (*UserPolicyAttachmentsExclusive, error)public static UserPolicyAttachmentsExclusive Get(string name, Input<string> id, UserPolicyAttachmentsExclusiveState? state, CustomResourceOptions? opts = null)public static UserPolicyAttachmentsExclusive get(String name, Output<String> id, UserPolicyAttachmentsExclusiveState state, CustomResourceOptions options)resources: _: type: aws:iam:UserPolicyAttachmentsExclusive get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Policy
Arns List<string> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- Policy
Arns []string - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- policy
Arns List<String> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
- policy
Arns string[] - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name string - IAM user name.
- policy_
arns Sequence[str] - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user_
name str - IAM user name.
- policy
Arns List<String> - A list of managed IAM policy ARNs to be attached to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
Import
Using pulumi import, import exclusive management of managed IAM policy assignments using the userName. For example:
$ pulumi import aws:iam/userPolicyAttachmentsExclusive:UserPolicyAttachmentsExclusive example MyUser
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
published on Tuesday, Mar 31, 2026 by Pulumi
