How to use MFA with AWS CLI?

前端 未结 13 1336
太阳男子
太阳男子 2020-12-05 00:05

How do I type in the MFA code when using the AWS CLI? I have checked the documentation page of IAM http://docs.aws.amazon.com/cli/latest/reference/iam/index.html.

I

13条回答
  •  臣服心动
    2020-12-05 00:52

    I have forked Chinmay's gist and updated it to pull the device serial from aws instead of hardcoding it. I have also updated the exits to return a status of 1 instead of just exiting.

    Available here: https://gist.github.com/jpribyl/e44021ae5cbf7fd1b4549598e85b5341

    I am using it in deploy scripts like this (I renamed the script to awsMfaCli.sh):

    . awsMfaCli.sh
    script_status=$?
    
    if [[ $script_status -ne 1 ]]; then
        echo "Building production"
        if npm run build ; then
           echo "Build Successful"
        else
          echo "Error building, exiting.."
          return 1
        fi
    
    
        echo "Removing all files on bucket.."
        aws s3 rm --recursive s3://mybucket
    
        echo "Uploading site.."
        aws s3 sync build/ s3://mybucket
        echo "S3 Upload complete.."
        echo "Deployment complete."
    else
        return 1
    fi
    

提交回复
热议问题