question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IAM User.fromUserName does not implement IUser functions

See original GitHub issue

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

Reproduction Steps

import { PolicyStatement, User } from '@aws-cdk/aws-iam';

const importedUser = User.fromUserName(this, 'ImportedUser', 'my-user');
importedUser.attachInlinePolicy(new PolicyStatement({...}));

Error Log

Cannot add inline policy to imported User

Environment

  • CLI Version : 1.20.0
  • Framework Version : 1.20.0
  • OS : Mac OS
  • Language : Typescript 3.7.0

Other

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 Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
rangojucommented, Jan 31, 2020

@rix0rrr , I had the exact same usecase. Do you happen to know the reason why this was on purpose?

1reaction
mariusingjercommented, Sep 21, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class User (construct) · AWS CDK - AWS Documentation
Type: SecretValue (optional, default: User won't be able to access the management console without a password.) The password for the user. This is...
Read more >
Store does not implement IUserRoleStore<TUser ...
My solution is working with the SignInManager for passwords but I can not get it to get passed the error for Roles. ConfigureServices...
Read more >
How to Import an Existing IAM User in AWS CDK | bobbyhadz
The most common method to import an existing IAM User in CDK is by the username. To import a user by the username...
Read more >
awsiam - Go Packages
Customize the creation of IAM roles within the given scope. It is recommended that you **do not** use this method and instead allow...
Read more >
@aws-cdk/aws-cognito - npm
Features such as Multi-factor authentication (MFAs) and Lambda Triggers are not configured by default. Use the grant() method to add an IAM policy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found