Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulumi tries to replace iam.UserLoginProfile if passwordResetRequired is set, the password was changed and the stack refreshed #3750

Closed
rafalkrupinski opened this issue Mar 28, 2024 · 6 comments
Assignees
Labels
area/docs Improvements or additions to documentation area/refresh awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/no-repro This issue wasn't able to be reproduced
Milestone

Comments

@rafalkrupinski
Copy link

rafalkrupinski commented Mar 28, 2024

What happened?

  1. Called pulumi up to create resources as in the example
  2. logged in as the newly created user, changed password as required
  3. called pulumi refresh - detects change of passwordResetRequired to false
  4. called pulumi up

At the last step pulumi reports the login profile will be replaced, but fails to create a second login profile for the user before the old one is removed, while it shouldn't try replacing the login profile at all.
Documentation for passwordResetRequired says it Only applies at resource creation.

    error: 1 error occurred:
        * creating IAM User Login Profile for "testUser": EntityAlreadyExists: Login Profile for user testUser already exists.
        status code: 409, request id: ae0179e8-31b7-4671-b433-f5514cc315ff

Example

import * as aws from "@pulumi/aws";

const user = new aws.iam.User(
    'testuser',
    {
        name: 'testUser',
    } 
);

const loginProfile = new aws.iam.UserLoginProfile(
    "testLoginProfile",
    {
        user: user.name,
        passwordResetRequired: true,
    }
);

export const testPassword = loginProfile.password; // only needed to login

new aws.iam.UserPolicy("allowChangeOwnPassword", { //only needed to change the password at login
    user: user.name,
    policy: {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": "iam:GetAccountPasswordPolicy",
                "Resource": "*"
            },
            {
                "Effect": "Allow",
                "Action": "iam:ChangePassword",
                "Resource": user.arn,
            },
            {
                Effect: "Allow",
                Action: "iam:GetUser",
                Resource: user.arn,
            }
        ]
    }
});

Output of pulumi about

CLI
Version 3.111.1
Go Version go1.22.1
Go Compiler gc

Host
OS debian
Version 12.5
Arch x86_64

Pulumi locates its logs in /tmp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@rafalkrupinski rafalkrupinski added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Mar 28, 2024
@rafalkrupinski rafalkrupinski changed the title iam.UserLoginProfile.passwordResetRequired not retained after refresh Pulumi trie to replace iam.UserLoginProfile if passwordResetRequired is set, the password was changed and the stack refreshed Mar 28, 2024
@rafalkrupinski rafalkrupinski changed the title Pulumi trie to replace iam.UserLoginProfile if passwordResetRequired is set, the password was changed and the stack refreshed Pulumi tries to replace iam.UserLoginProfile if passwordResetRequired is set, the password was changed and the stack refreshed Mar 28, 2024
@corymhall
Copy link
Contributor

@rafalkrupinski it looks like this is working as the upstream provider intended, although the documentation is definitely a little confusing (not sure why it mentions creation when updating is not possible). I think the way to handle this is with the ignoreChanges resource option.

@corymhall corymhall added area/docs Improvements or additions to documentation and removed kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Mar 29, 2024
@rafalkrupinski
Copy link
Author

Can't imagine it's an intended behaviour. Hope the bug report from a pulumi user is honoured by the upstream maintainers.

@corymhall corymhall added the awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). label Mar 29, 2024
@mikhailshilkov
Copy link
Member

The property is indeed marked as ForceNew upstream: https://github.com/hashicorp/terraform-provider-aws/blob/0d1d7b6c5eb9f8e2c5265b35df7ddde5852c15d8/internal/service/iam/user_login_profile.go#L58

We mark it as such too
image

The property description is translated faithfully from the upstream docs
image

So I think our behavior is by design here.

@corymhall Do you want to keep the issue open to track any work on our side? If so, please label it with a kind/ label.

@rafalkrupinski
Copy link
Author

rafalkrupinski commented Apr 1, 2024

From a user perspective it doesn't work as intended. The flag should apply only on resource creation, and I (as a user) know nothing of ForceNew.

To me it seems it's an undesired combined effect of aws changing the field after fulfilling its desired purpose + ForceNew. The password_reset_required shouldn't update when that field in AWS changes, or rather, there should be separate flag that only sets password_reset_required on creation, as it's now documented.

I realize it's an upstream problem, and I've reported it there too.

@rafalkrupinski
Copy link
Author

rafalkrupinski commented Apr 1, 2024

upstream issue hashicorp/terraform-provider-aws#23567

@mikhailshilkov mikhailshilkov added the kind/bug Some behavior is incorrect or out of spec label Apr 2, 2024
@t0yv0
Copy link
Member

t0yv0 commented Apr 26, 2024

The upstream issue got fixed by not changing passwordResetRequired in Read: https://github.com/hashicorp/terraform-provider-aws/pull/36926/files#diff-7b4e00a7f40cb5504072acf00eb8a74f6f24ab1fa0336bdebebc67c77516a6f0

This is now inherited by pulumi. pulumi refresh now does not detect changes in this scenario.

CLI          
Version      3.111.1
Go Version   go1.22.1
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.32.0
awsx    2.9.0
docker  4.5.3
docker  3.6.1
nodejs  unknown

Host     
OS       darwin
Version  14.4.1
Arch     x86_64

This project is written in nodejs: executable='/Users/t0yv0/bin/node' version='v18.18.2'

Current Stack: anton-pulumi-corp/aws-3750/dev

TYPE                                       URN
pulumi:pulumi:Stack                        urn:pulumi:dev::aws-3750::pulumi:pulumi:Stack::aws-3750-dev
pulumi:providers:aws                       urn:pulumi:dev::aws-3750::pulumi:providers:aws::default_6_32_0
aws:iam/user:User                          urn:pulumi:dev::aws-3750::aws:iam/user:User::testuser
aws:iam/userLoginProfile:UserLoginProfile  urn:pulumi:dev::aws-3750::aws:iam/userLoginProfile:UserLoginProfile::testLoginProfile
aws:iam/userPolicy:UserPolicy              urn:pulumi:dev::aws-3750::aws:iam/userPolicy:UserPolicy::allowChangeOwnPassword


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/anton-pulumi-corp
User           anton-pulumi-corp
Organizations  anton-pulumi-corp, moolumi, pulumi
Token type     personal

Dependencies:
NAME            VERSION
@types/node     18.19.31
typescript      5.4.5
@pulumi/aws     6.32.0
@pulumi/awsx    2.9.0
@pulumi/pulumi  3.113.3

Pulumi locates its logs in /var/folders/gk/cchgxh512m72f_dmkcc3d09h0000gp/T/com.apple.shortcuts.mac-helper// by default

I'm going to close as fixed but please open a new issue if there's something else that can be improved here.

@t0yv0 t0yv0 added this to the 0.103 milestone Apr 26, 2024
@t0yv0 t0yv0 self-assigned this Apr 26, 2024
@t0yv0 t0yv0 added the resolution/fixed This issue was fixed label Apr 26, 2024
@t0yv0 t0yv0 closed this as completed Apr 26, 2024
@t0yv0 t0yv0 added resolution/no-repro This issue wasn't able to be reproduced and removed resolution/fixed This issue was fixed labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation area/refresh awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/no-repro This issue wasn't able to be reproduced
Projects
None yet
Development

No branches or pull requests

4 participants