When trying to create an IAM User from @aws-cdk/aws-iam
with User.fromUserName
the following IUser functions throw an erro.
addToGroup
attachInlinePolicy
addManagedPolicy
https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-iam/lib/user.ts#L145-L154
import { PolicyStatement, User } from '@aws-cdk/aws-iam';
const importedUser = User.fromUserName(this, 'ImportedUser', 'my-user');
importedUser.attachInlinePolicy(new PolicyStatement({...}));
Cannot add inline policy to imported User
https://gitter.im/awslabs/aws-cdk?at=5dc31ea914d55a3785e7ca39 (Other people are having this problem)
https://github.com/aws/aws-cdk/pull/3738 (PR implementation of IUser)
https://github.com/aws/aws-cdk/issues/3490 (issue associated with PR)
This is :bug: Bug Report
More of a feature request than a bug. We didn't implement this on purpose (apparently).
Can you describe your use case?
There was a user created manually in my aws account and now I need to add extra policies to that user.
@rix0rrr , I had the exact same usecase. Do you happen to know the reason why this was on purpose?
We have the exact same scenario: iam user creation is disabled, they opened up for a short time so we could manually create a build user for our service, now I want to configure that build user with CDK.
Most helpful comment
@rix0rrr , I had the exact same usecase. Do you happen to know the reason why this was on purpose?