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

UserPoolGroup has different LogicalID when upgrading from amplify-cli 9 to 12 #13648

Closed
NickDario opened this issue Mar 14, 2024 · 2 comments
Closed
Labels
pending-triage Issue is pending triage question General question

Comments

@NickDario
Copy link

NickDario commented Mar 14, 2024

Amplify CLI Version

12

Question

Hello!

I am encountering an error when pushing a userPoolGroups stack

MYGROUP already exists in stack arn:aws:cloudformation:us-west-2:...

I previously deployed an amplify userPoolGroup stack using amplify CLI 9 which allowed direct changes to the cloud formation template. We added several userPoolGroups to the template using logicalIDs that didn't append "Group".

This appears to an issue as when deploying in amplify cli 12 it generates CF templates with "Group" appended to all user pool group logicalIDs (so [MyGroupName]Group)

For the groups we created in amplify CLI 9 that have "Group" appended it correctly registers as an update to an existing user pool group, however for the few that have the different logicalIDs it fails since it views them as new user pool groups, and encounters an error when attempting to create them.

Is it possible to modify the logicalID using override.ts or some other method?

previous template we deployed via cli 9

{
   ...
   Resources: {
     ...
    "MYGROUP": {
      "Type": "AWS::Cognito::UserPoolGroup",
      "Properties": {
        "UserPoolId": {
          "Ref": "authwwwUserPoolId"
        },
        "Description": "override success",
        "GroupName": "MYGROUP",
        "Precedence": 116,
        "RoleArn": {
          "Fn::GetAtt": ["MYGROUPGroupRole", "Arn"]
        }
      }
    },
   ...
   }
}

generated by amplify-cli 12 during amplify push

{
   ...
   Resources: {
     ...
    "MYGROUPGroup": {
      "Type": "AWS::Cognito::UserPoolGroup",
      "Properties": {
        "UserPoolId": {
          "Ref": "authwwwUserPoolId"
        },
        "Description": "override success",
        "GroupName": "MYGROUP",
        "Precedence": 116,
        "RoleArn": {
          "Fn::GetAtt": ["MYGROUPGroupRole", "Arn"]
        }
      }
    },
   ...
   }
}

I have tried using override.ts but I haven't found a way to change the logicalID, based on the typescript types it doesn't seem to be an available field.

If the logicalID cannot be changed, is there another method I can use to deploy that doesn't remove the existing groups which are in use?

@NickDario NickDario added pending-triage Issue is pending triage question General question labels Mar 14, 2024
@NickDario
Copy link
Author

NickDario commented Mar 14, 2024

I found the function overrideLogicalId which worked

function removeGroupSuffixFromUserPoolLogicalID(
  resources: AmplifyUserPoolGroupStackTemplate,
  group: string,
) {
  if (resources.userPoolGroup && resources.userPoolGroup[group]) {
    console.log(`removeGroupSuffixFromUserPoolLogicalID for ${group}`);
    resources.userPoolGroup[group].overrideLogicalId(group);
  } else {
    console.log(`cannot removeGroupSuffixFromUserPoolLogicalID, no userPoolGroup for ${group}`);
  }
}

export function override(
  resources: AmplifyUserPoolGroupStackTemplate,
  amplifyProjectInfo: AmplifyProjectInfo,
) {
    //  these groups were created in Amplify CLI 9 using a name different than the generated group name.
    removeGroupSuffixFromUserPoolLogicalID(resources, 'MYGROUP');
}

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-triage Issue is pending triage question General question
Projects
None yet
Development

No branches or pull requests

1 participant