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

aws command failed #14

Closed
Venus713 opened this issue Mar 2, 2021 · 3 comments
Closed

aws command failed #14

Venus713 opened this issue Mar 2, 2021 · 3 comments

Comments

@Venus713
Copy link

Venus713 commented Mar 2, 2021

Hi,

I am working to run aws command using your package in nodejs.
My code did work in the old version of your package, but after upgrading the package, it doesn't work now.
For example, this code did work in old version.

snsCallerArn = await aws.command(
        `iam create-role \
                --path /service-role/ \
                --role-name ${roleName} \
                --assume-role-policy-document file://src/tmp/${externalId}/resources/role-trust-policy.json`
      ).then(function (data) {
        console.log('data in creating service role =', data)
        logger.default.debug('data in creating service role =', data)
        return data.object.Role.Arn
      })

But it doesn't work in latest version, so I updated it and it does work.

snsCallerArn = await aws.command(
        `iam create-role --path /service-role/ --role-name ${roleName} --assume-role-policy-document file://src/tmp/${externalId}/resources/role-trust-policy.json`
      ).then(function (data) {
        console.log('data in creating service role =', data)
        logger.default.debug('data in creating service role =', data)
        return data.object.Role.Arn
      })

In other words, I removed the symbol \.
But I need to use the symbol \ because it requires a lot of parameters when creating cognito-user-pool.
For example,

userPoolId = await aws.command(
      `cognito-idp create-user-pool \
            --pool-name ${stackName} \
            --auto-verified-attributes email phone_number \
            --alias-attributes email phone_number preferred_username \
            --sms-verification-message 'Your authentication code for ${stackName} is {####}.' \
            --email-verification-message 'Your authentication code for ${stackName} is {####}.' \
            --email-verification-subject 'Your Verification Code for ${stackName}.' \
            --sms-authentication-message 'Your authentication code for ${stackName} is {####}.' \
            --mfa-configuration OPTIONAL \
            --email-configuration EmailSendingAccount='DEVELOPER',SourceArn='arn:aws:ses:${region}:${awsAccountId}:identity/${customerEmail}',From='${customerEmail}',customerEmailEmailAddress='${customerEmail}' \
            --sms-configuration SnsCallerArn=arn:aws:iam::${awsAccountId}:role/service-role/${roleName},ExternalId=${externalId} \
            --account-recovery-setting RecoveryMechanisms=[{Priority=1,Name=verified_email},{Priority=2,Name=verified_phone_number}] \
            --device-configuration ChallengeRequiredOnNewDevice=false,DeviceOnlyRememberedOnUserPrompt=false \
            --verification-message-template '{"DefaultEmailOption":"CONFIRM_WITH_LINK","EmailSubjectByLink":"Your verification link","EmailMessageByLink":"Please click the link below to verify your email address. {##Verify Email##}","SmsMessage":"Your authentication code for ${stackName} is {####}."}' \
            --admin-create-user-config '{"AllowAdminCreateUserOnly":false,"InviteMessageTemplate":{"EmailMessage":"Your username for ${stackName} is {username} and temporary password is {####}.","EmailSubject":"Your temporary password for ${stackName}","SMSMessage":"Your username for ${stackName} is {username} and temporary password is {####}."},"UnusedAccountValidityDays":7}' \
            `
    ).then(function (data) {
      console.log('data in creating user-pool =', data)
      logger.default.debug('data in creating user-pool =', data)
      return data.object.UserPool.Id
    })

What do you have any suggestion?

@mattqs
Copy link
Contributor

mattqs commented Mar 3, 2021

The reason is

[...command.split(' ')] 

introduced by commit
1d0525a#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80

@69

I will fix and publish new release.

@mattqs mattqs closed this as completed in 29bf364 Mar 3, 2021
@mattqs
Copy link
Contributor

mattqs commented Mar 3, 2021

@Venus713
Copy link
Author

Venus713 commented Mar 5, 2021

Hi @mattqs
Thank you. I will try it with the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants