User Policy Attachment Args
data class UserPolicyAttachmentArgs(val policyArn: Output<String>? = null, val user: Output<String>? = null) : ConvertibleToJava<UserPolicyAttachmentArgs>
Attaches a Managed IAM Policy to an IAM user
NOTE: The usage of this resource conflicts with the
aws.iam.PolicyAttachment
resource and will permanently show a difference if both are defined.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.User;
import com.pulumi.aws.iam.Policy;
import com.pulumi.aws.iam.PolicyArgs;
import com.pulumi.aws.iam.UserPolicyAttachment;
import com.pulumi.aws.iam.UserPolicyAttachmentArgs;
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 user = new User("user");
var policy = new Policy("policy", PolicyArgs.builder()
.description("A test policy")
.policy("{ ... policy JSON ... }")
.build());
var test_attach = new UserPolicyAttachment("test-attach", UserPolicyAttachmentArgs.builder()
.user(user.name())
.policyArn(policy.arn())
.build());
}
}
Content copied to clipboard
Import
IAM user policy attachments can be imported using the user name and policy arn separated by /
.
$ pulumi import aws:iam/userPolicyAttachment:UserPolicyAttachment test-attach test-user/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy
Content copied to clipboard