diff --git a/lib/plugins/interactiveCli/setupAws.js b/lib/plugins/interactiveCli/setupAws.js index 45bb88911..49f0fc83b 100644 --- a/lib/plugins/interactiveCli/setupAws.js +++ b/lib/plugins/interactiveCli/setupAws.js @@ -6,28 +6,9 @@ const inquirer = require('./inquirer'); const awsCredentials = require('../aws/utils/credentials'); const { confirm } = require('./utils'); -const isValidAwsProfileName = RegExp.prototype.test.bind(/^[a-zA-Z][a-zA-Z0-9-]{0,100}$/); const isValidAwsAccessKeyId = RegExp.prototype.test.bind(/^[A-Z0-9]{10,}$/); const isValidAwsSecretAccessKey = RegExp.prototype.test.bind(/^[a-zA-Z0-9/+]{10,}$/); -const awsProfileNameInput = () => - inquirer - .prompt({ - message: 'AWS Profile name:', - type: 'input', - name: 'profileName', - validate: input => { - if (isValidAwsProfileName(input.trim())) return true; - return ( - 'AWS profile name is not valid.\n' + - ' - It should only contain alphanumeric and hyphens.\n' + - ' - It should start with an alphabetic character.\n' + - " - Shouldn't exceed 128 characters" - ); - }, - }) - .then(({ profileName }) => profileName.trim()); - const awsAccessKeyIdInput = () => inquirer .prompt({ @@ -84,21 +65,19 @@ https://serverless.com/framework/docs/providers/aws/guide/credentials#creating-a 'https://github.com/serverless/enterprise/blob/master/docs/setup-aws-account.md' )}\nThen enter them here:\n\n` ); - return awsProfileNameInput().then(profileName => - awsAccessKeyIdInput().then(accessKeyId => - awsSecretAccessKeyInput().then(secretAccessKey => - awsCredentials - .saveFileProfiles(new Map([[profileName, { accessKeyId, secretAccessKey }]])) - .then(() => - process.stdout.write( - `\n${chalk.green( - `AWS credentials saved on your machine at ${chalk.bold( - '~/.aws/credentials' - )}. Go there to change them at any time.` - )}\n` - ) + return awsAccessKeyIdInput().then(accessKeyId => + awsSecretAccessKeyInput().then(secretAccessKey => + awsCredentials + .saveFileProfiles(new Map([['default', { accessKeyId, secretAccessKey }]])) + .then(() => + process.stdout.write( + `\n${chalk.green( + `AWS credentials saved on your machine at ${chalk.bold( + '~/.aws/credentials' + )}. Go there to change them at any time.` + )}\n` ) - ) + ) ) ); });