使用多个帐户时无法创建新阶段?

时间:2016-03-15 16:07:03

标签: amazon-web-services amazon-s3 aws-lambda aws-api-gateway serverless-framework

所以我为不同的环境设置了多个帐户,当我尝试创建一个新阶段时,我得到“存在桶,你没有权限”。检查我的AWS权限后,我的开发和测试是相同的;知道为什么会这样吗?

对于dev,我没有创建问题; cf,s3 bucket,sls文件夹内的项目。

为了测试,我得到了上述错误;存储桶不存在它说存在存在且我没有许可。

首先运行:

yaos-imac:serverless yao$ sls project create
 _______                             __
|   _   .-----.----.--.--.-----.----|  .-----.-----.-----.
|   |___|  -__|   _|  |  |  -__|   _|  |  -__|__ --|__ --|
|____   |_____|__|  \___/|_____|__| |__|_____|_____|_____|
|   |   |             The Serverless Application Framework
|       |                           serverless.com, v0.5.0
`-------'

Serverless: Initializing Serverless Project...
Serverless: Enter a name for this project:  (serverless-vkkxnm) planet-express
Serverless: Enter a unique project bucket name (using a domain is recommended):  (serverless-vkkxnm.com) sls.planet-express.com
Serverless: Pick the primary region for your project:
  > us-east-1
    us-west-2
    eu-west-1
    ap-northeast-1
Serverless: Do you want to create a new stage and region for this project?
  > Yes
    No
Serverless: Enter a new stage name for this project:  dev
Serverless: For the "dev" stage, do you want to use an existing Amazon Web Services profile or create a new one?
  > Existing Profile
    Create A New Profile
Serverless: Select a profile for your project:
  > dev
    test
Serverless: Creating stage "dev"...
Serverless: Creating region "us-east-1" in stage "dev"...
Serverless: Deploying resources to stage "dev" in region "us-east-1" via Cloudformation (~3 minutes)...
Serverless: / Serverless: Creating your project bucket on S3: sls.planet-express.com...
Serverless: Successfully deployed "dev" resources to "us-east-1"
Serverless: Successfully created region "us-east-1" within stage "dev"
Serverless: Successfully created stage "dev"
Serverless: Successfully initialized project "planet-express"

现在我尝试创建一个新阶段:

yaos-imac:planet-express yao$ sls stage create
Serverless: Enter a new stage name for this project:  test
Serverless: For the "test" stage, do you want to use an existing Amazon Web Services profile or create a new one?
  > Existing Profile
    Create A New Profile
Serverless: Select a profile for your project:
    dev
  > test
Serverless: Creating stage "test"...
Serverless: Select a new region for your existing stage:
  > us-east-1
    us-west-2
    eu-west-1
    ap-northeast-1
Serverless: Creating region "us-east-1" in stage "test"...
Serverless: Deploying resources to stage "test" in region "us-east-1" via Cloudformation (~3 minutes)...
/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:49
        fn = function () { throw arg; };
                           ^

ServerlessError: ServerlessError: S3 Bucket "sls.planet-express.com" already exists and you do not have permissions to use it
    at new ServerlessError (/Users/yao/.node/lib/node_modules/serverless/lib/Error.js:17:11)
    at ResourcesDeploy.<anonymous> (/Users/yao/.node/lib/node_modules/serverless/lib/actions/ResourcesDeploy.js:252:21)
    at ResourcesDeploy.tryCatcher (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:503:31)
    at Promise._settlePromise (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:560:18)
    at Promise._settlePromise0 (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:605:10)
    at Promise._settlePromises (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:680:18)
    at Async._drainQueue (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:126:16)
    at Async._drainQueues (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:136:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/yao/.node/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:16:14)
    at processImmediate [as _immediateCallback] (timers.js:368:17)

1 个答案:

答案 0 :(得分:2)

正如comments中已经回答的那样,广告知识名称是全局唯一。如果您使用一个AWS账户创建项目,则无法使用其他AWS账户在同一项目中添加新阶段,因为存储桶名称将不可用,即使它位于另一个AWS区域中。

根据docs

  

无论AWS如何,Amazon S3存储桶名称都是全球唯一的   您创建存储桶的区域。


在S3中托管静态网站时,这是一个很大的问题,因为存储桶名称必须与域名匹配。如果已经采用了存储桶名称,则无法将其托管在那里。