published on Wednesday, Mar 11, 2026 by Pulumi
published on Wednesday, Mar 11, 2026 by Pulumi
Resource for maintaining exclusive management of inline policies assigned to an AWS IAM (Identity & Access Management) user.
!> This resource takes exclusive ownership over inline policies assigned to a user. This includes removal of inline policies which are not explicitly configured. To prevent persistent drift, ensure any aws.iam.UserPolicy resources managed alongside this resource are included in the policy_names argument.
Destruction of this resource means Terraform will no longer manage reconciliation of the configured inline policy assignments. It will not delete 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.UserPoliciesExclusive("example", {
userName: exampleAwsIamUser.name,
policyNames: [exampleAwsIamUserPolicy.name],
});
import pulumi
import pulumi_aws as aws
example = aws.iam.UserPoliciesExclusive("example",
user_name=example_aws_iam_user["name"],
policy_names=[example_aws_iam_user_policy["name"]])
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.NewUserPoliciesExclusive(ctx, "example", &iam.UserPoliciesExclusiveArgs{
UserName: pulumi.Any(exampleAwsIamUser.Name),
PolicyNames: pulumi.StringArray{
exampleAwsIamUserPolicy.Name,
},
})
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.UserPoliciesExclusive("example", new()
{
UserName = exampleAwsIamUser.Name,
PolicyNames = new[]
{
exampleAwsIamUserPolicy.Name,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.UserPoliciesExclusive;
import com.pulumi.aws.iam.UserPoliciesExclusiveArgs;
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 UserPoliciesExclusive("example", UserPoliciesExclusiveArgs.builder()
.userName(exampleAwsIamUser.name())
.policyNames(exampleAwsIamUserPolicy.name())
.build());
}
}
resources:
example:
type: aws:iam:UserPoliciesExclusive
properties:
userName: ${exampleAwsIamUser.name}
policyNames:
- ${exampleAwsIamUserPolicy.name}
Disallow Inline Policies
To automatically remove any configured inline policies, set the policy_names argument to an empty list.
This will not prevent inline policies from being assigned to a user via Terraform (or any other interface). This resource enables bringing inline 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.UserPoliciesExclusive("example", {
userName: exampleAwsIamUser.name,
policyNames: [],
});
import pulumi
import pulumi_aws as aws
example = aws.iam.UserPoliciesExclusive("example",
user_name=example_aws_iam_user["name"],
policy_names=[])
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.NewUserPoliciesExclusive(ctx, "example", &iam.UserPoliciesExclusiveArgs{
UserName: pulumi.Any(exampleAwsIamUser.Name),
PolicyNames: 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.UserPoliciesExclusive("example", new()
{
UserName = exampleAwsIamUser.Name,
PolicyNames = new[] {},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.UserPoliciesExclusive;
import com.pulumi.aws.iam.UserPoliciesExclusiveArgs;
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 UserPoliciesExclusive("example", UserPoliciesExclusiveArgs.builder()
.userName(exampleAwsIamUser.name())
.policyNames()
.build());
}
}
resources:
example:
type: aws:iam:UserPoliciesExclusive
properties:
userName: ${exampleAwsIamUser.name}
policyNames: []
Create UserPoliciesExclusive Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserPoliciesExclusive(name: string, args: UserPoliciesExclusiveArgs, opts?: CustomResourceOptions);@overload
def UserPoliciesExclusive(resource_name: str,
args: UserPoliciesExclusiveArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserPoliciesExclusive(resource_name: str,
opts: Optional[ResourceOptions] = None,
policy_names: Optional[Sequence[str]] = None,
user_name: Optional[str] = None)func NewUserPoliciesExclusive(ctx *Context, name string, args UserPoliciesExclusiveArgs, opts ...ResourceOption) (*UserPoliciesExclusive, error)public UserPoliciesExclusive(string name, UserPoliciesExclusiveArgs args, CustomResourceOptions? opts = null)
public UserPoliciesExclusive(String name, UserPoliciesExclusiveArgs args)
public UserPoliciesExclusive(String name, UserPoliciesExclusiveArgs args, CustomResourceOptions options)
type: aws:iam:UserPoliciesExclusive
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 UserPoliciesExclusiveArgs
- 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 UserPoliciesExclusiveArgs
- 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 UserPoliciesExclusiveArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserPoliciesExclusiveArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserPoliciesExclusiveArgs
- 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 userPoliciesExclusiveResource = new Aws.Iam.UserPoliciesExclusive("userPoliciesExclusiveResource", new()
{
PolicyNames = new[]
{
"string",
},
UserName = "string",
});
example, err := iam.NewUserPoliciesExclusive(ctx, "userPoliciesExclusiveResource", &iam.UserPoliciesExclusiveArgs{
PolicyNames: pulumi.StringArray{
pulumi.String("string"),
},
UserName: pulumi.String("string"),
})
var userPoliciesExclusiveResource = new UserPoliciesExclusive("userPoliciesExclusiveResource", UserPoliciesExclusiveArgs.builder()
.policyNames("string")
.userName("string")
.build());
user_policies_exclusive_resource = aws.iam.UserPoliciesExclusive("userPoliciesExclusiveResource",
policy_names=["string"],
user_name="string")
const userPoliciesExclusiveResource = new aws.iam.UserPoliciesExclusive("userPoliciesExclusiveResource", {
policyNames: ["string"],
userName: "string",
});
type: aws:iam:UserPoliciesExclusive
properties:
policyNames:
- string
userName: string
UserPoliciesExclusive 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 UserPoliciesExclusive resource accepts the following input properties:
- Policy
Names List<string> - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- Policy
Names []string - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- policy
Names List<String> - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
- policy
Names string[] - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name string - IAM user name.
- policy_
names Sequence[str] - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user_
name str - IAM user name.
- policy
Names List<String> - A list of inline policy names to be assigned 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 UserPoliciesExclusive 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 UserPoliciesExclusive Resource
Get an existing UserPoliciesExclusive 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?: UserPoliciesExclusiveState, opts?: CustomResourceOptions): UserPoliciesExclusive@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
policy_names: Optional[Sequence[str]] = None,
user_name: Optional[str] = None) -> UserPoliciesExclusivefunc GetUserPoliciesExclusive(ctx *Context, name string, id IDInput, state *UserPoliciesExclusiveState, opts ...ResourceOption) (*UserPoliciesExclusive, error)public static UserPoliciesExclusive Get(string name, Input<string> id, UserPoliciesExclusiveState? state, CustomResourceOptions? opts = null)public static UserPoliciesExclusive get(String name, Output<String> id, UserPoliciesExclusiveState state, CustomResourceOptions options)resources: _: type: aws:iam:UserPoliciesExclusive 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
Names List<string> - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- Policy
Names []string - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- User
Name string - IAM user name.
- policy
Names List<String> - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name String - IAM user name.
- policy
Names string[] - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user
Name string - IAM user name.
- policy_
names Sequence[str] - A list of inline policy names to be assigned to the user. Policies attached to this user but not configured in this argument will be removed.
- user_
name str - IAM user name.
- policy
Names List<String> - A list of inline policy names to be assigned 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 inline policy assignments using the user_name. For example:
$ pulumi import aws:iam/userPoliciesExclusive:UserPoliciesExclusive 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 Wednesday, Mar 11, 2026 by Pulumi
