We have a simple serverless application that contains a dynamo DB table, a few lambdas and an API endpoint. We currently have the app deployed in the dev stage.
We are having some trouble deploying to the prod stage.
Here is the serverless.yaml file.
service: lookups
# app and org for use with dashboard.# serverless.com
app: lookups
org: xxxxxx
provider:
name: aws
runtime: python3.8
environment:
DYNAMO_DB_LOOKUP_TABLE_NAME: lookup_${self:provider.stage}
S3_BUCKET: com.yyyyy.lookups.${self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:GetItem
Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.DYNAMO_DB_LOOKUP_TABLE_NAME}"
functions:
createOrUpdateLookups:
handler: createOrUpdateLookups.createOrUpdateLookups
description: create or update lookup entry in dynamodb
environment:
lookupTable: ${self:provider.environment.DYNAMO_DB_LOOKUP_TABLE_NAME}
events:
- s3:
bucket: ${self:provider.environment.S3_BUCKET}
event: s3:ObjectCreated:*
rules:
- suffix: .json
getLookup:
handler: getLookup.getLookup
description: get persigned url for a lookup by location and lookup type
environment:
lookupTable: ${self:provider.environment.DYNAMO_DB_LOOKUP_TABLE_NAME}
lookupBucket: ${self:provider.environment.S3_BUCKET}
events:
- http:
path: v1/lookup
method: get
request:
parameters:
querystrings:
location: true
lookupType: true
resources:
Resources:
lookupTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
TableName: ${self:provider.environment.DYNAMO_DB_LOOKUP_TABLE_NAME}
AttributeDefinitions:
- AttributeName: location
AttributeType: S
- AttributeName: lookup
AttributeType: S
KeySchema:
- AttributeName: location
KeyType: "HASH"
- AttributeName: lookup
KeyType: "RANGE"
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
We deployed this to the dev stage using the following cli command:
serverless deploy
This created a stack in CloudFormtion called lookups-dev
, a DymanoDB table DB table called lookup-dev
and lambdas called lookups-dev-createOrUpdateLookups
and lookups-dev-getLookup
.
Now when try to deploy to a new stage called prod using this cli command
serverless deploy --stage prod
We get an error saying the table lookups-dev already exists in the stack with the stack id of the lookups-dev stack.
This is the full error:
An error occurred: lookupTable - lookup_dev already exists in stack arn:aws:cloudformation:us-east-1:aaaaabbbbbbbccccccdddddd:stack/lookups-dev/wwwwwww-wwwwwww-wwwwwwaws.
Question:
How do we deploy to a new stage when we have already deployed out app the dev stage.