Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01d3ae3

Browse files
committed
Implementado passagem de parametro ao comando para realizar deploy, poder definir stage.
1 parent 866c6c1 commit 01d3ae3

5 files changed

+61
-48
lines changed
491 Bytes
Binary file not shown.

.serverless/cloudformation-template-update-stack.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"HelloLogGroup": {
6060
"Type": "AWS::Logs::LogGroup",
6161
"Properties": {
62-
"LogGroupName": "/aws/lambda/api-python-hello-world-dev-hello"
62+
"LogGroupName": "/aws/lambda/api-python-hello-world-homologacao-hello"
6363
}
6464
},
6565
"IamRoleLambdaExecution": {
@@ -88,7 +88,7 @@
8888
"-",
8989
[
9090
"api-python-hello-world",
91-
"dev",
91+
"homologacao",
9292
"lambda"
9393
]
9494
]
@@ -104,7 +104,7 @@
104104
],
105105
"Resource": [
106106
{
107-
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-dev*:*"
107+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-homologacao*:*"
108108
}
109109
]
110110
},
@@ -115,7 +115,7 @@
115115
],
116116
"Resource": [
117117
{
118-
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-dev*:*:*"
118+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-homologacao*:*:*"
119119
}
120120
]
121121
}
@@ -129,7 +129,7 @@
129129
"-",
130130
[
131131
"api-python-hello-world",
132-
"dev",
132+
"homologacao",
133133
{
134134
"Ref": "AWS::Region"
135135
},
@@ -146,9 +146,9 @@
146146
"S3Bucket": {
147147
"Ref": "ServerlessDeploymentBucket"
148148
},
149-
"S3Key": "serverless/api-python-hello-world/dev/1606250373036-2020-11-24T20:39:33.036Z/api-python-hello-world.zip"
149+
"S3Key": "serverless/api-python-hello-world/homologacao/1606308726502-2020-11-25T12:52:06.502Z/api-python-hello-world.zip"
150150
},
151-
"FunctionName": "api-python-hello-world-dev-hello",
151+
"FunctionName": "api-python-hello-world-homologacao-hello",
152152
"Handler": "src/item.hello_world",
153153
"MemorySize": 256,
154154
"Role": {
@@ -164,20 +164,20 @@
164164
"HelloLogGroup"
165165
]
166166
},
167-
"HelloLambdaVersion17IOIygMGs2nmaA3r9vypDFb4y68JKXVJYQxmT6sU": {
167+
"HelloLambdaVersiontl1PaqUWQaUSV63k1OivjVUiGn2YxNU8rVBD67hdzS0": {
168168
"Type": "AWS::Lambda::Version",
169169
"DeletionPolicy": "Retain",
170170
"Properties": {
171171
"FunctionName": {
172172
"Ref": "HelloLambdaFunction"
173173
},
174-
"CodeSha256": "xUV5Bo8pL1R46jPSEfLDg6FHEMl6K0YNrTxoeX2D2BE="
174+
"CodeSha256": "/tharYWbigYLNY+e6E4mtpjAwxqbS7GB65Kwd9V0bUc="
175175
}
176176
},
177177
"ApiGatewayRestApi": {
178178
"Type": "AWS::ApiGateway::RestApi",
179179
"Properties": {
180-
"Name": "dev-api-python-hello-world",
180+
"Name": "homologacao-api-python-hello-world",
181181
"EndpointConfiguration": {
182182
"Types": [
183183
"EDGE"
@@ -375,13 +375,13 @@
375375
]
376376
}
377377
},
378-
"ApiGatewayDeployment1606250371399": {
378+
"ApiGatewayDeployment1606308724338": {
379379
"Type": "AWS::ApiGateway::Deployment",
380380
"Properties": {
381381
"RestApiId": {
382382
"Ref": "ApiGatewayRestApi"
383383
},
384-
"StageName": "dev"
384+
"StageName": "homologacao"
385385
},
386386
"DependsOn": [
387387
"ApiGatewayMethodApiPythonHelloDashworldGet"
@@ -391,32 +391,32 @@
391391
"Type": "AWS::ApiGateway::ApiKey",
392392
"Properties": {
393393
"Enabled": true,
394-
"Name": "myKey",
394+
"Name": "homologacao-myKey",
395395
"StageKeys": [
396396
{
397397
"RestApiId": {
398398
"Ref": "ApiGatewayRestApi"
399399
},
400-
"StageName": "dev"
400+
"StageName": "homologacao"
401401
}
402402
]
403403
},
404-
"DependsOn": "ApiGatewayDeployment1606250371399"
404+
"DependsOn": "ApiGatewayDeployment1606308724338"
405405
},
406406
"ApiGatewayUsagePlan": {
407407
"Type": "AWS::ApiGateway::UsagePlan",
408-
"DependsOn": "ApiGatewayDeployment1606250371399",
408+
"DependsOn": "ApiGatewayDeployment1606308724338",
409409
"Properties": {
410410
"ApiStages": [
411411
{
412412
"ApiId": {
413413
"Ref": "ApiGatewayRestApi"
414414
},
415-
"Stage": "dev"
415+
"Stage": "homologacao"
416416
}
417417
],
418-
"Description": "Usage plan for api-python-hello-world dev stage",
419-
"UsagePlanName": "api-python-hello-world-dev"
418+
"Description": "Usage plan for api-python-hello-world homologacao stage",
419+
"UsagePlanName": "api-python-hello-world-homologacao"
420420
}
421421
},
422422
"ApiGatewayUsagePlanKey1": {
@@ -478,7 +478,7 @@
478478
"HelloLambdaFunctionQualifiedArn": {
479479
"Description": "Current Lambda function version",
480480
"Value": {
481-
"Ref": "HelloLambdaVersion17IOIygMGs2nmaA3r9vypDFb4y68JKXVJYQxmT6sU"
481+
"Ref": "HelloLambdaVersiontl1PaqUWQaUSV63k1OivjVUiGn2YxNU8rVBD67hdzS0"
482482
}
483483
},
484484
"ServiceEndpoint": {
@@ -499,7 +499,7 @@
499499
{
500500
"Ref": "AWS::URLSuffix"
501501
},
502-
"/dev"
502+
"/homologacao"
503503
]
504504
]
505505
}

.serverless/serverless-state.json

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"stage": "dev",
1212
"apiKeys": [
1313
{
14-
"name": "myKey"
14+
"name": "homologacao-myKey"
1515
}
1616
],
1717
"variableSyntax": "\\${([^{}:]+?(?:\\(|:)(?:[^:{}][^{}]*?)?)}",
@@ -77,7 +77,7 @@
7777
"HelloLogGroup": {
7878
"Type": "AWS::Logs::LogGroup",
7979
"Properties": {
80-
"LogGroupName": "/aws/lambda/api-python-hello-world-dev-hello"
80+
"LogGroupName": "/aws/lambda/api-python-hello-world-homologacao-hello"
8181
}
8282
},
8383
"IamRoleLambdaExecution": {
@@ -106,7 +106,7 @@
106106
"-",
107107
[
108108
"api-python-hello-world",
109-
"dev",
109+
"homologacao",
110110
"lambda"
111111
]
112112
]
@@ -122,7 +122,7 @@
122122
],
123123
"Resource": [
124124
{
125-
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-dev*:*"
125+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-homologacao*:*"
126126
}
127127
]
128128
},
@@ -133,7 +133,7 @@
133133
],
134134
"Resource": [
135135
{
136-
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-dev*:*:*"
136+
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/api-python-hello-world-homologacao*:*:*"
137137
}
138138
]
139139
}
@@ -147,7 +147,7 @@
147147
"-",
148148
[
149149
"api-python-hello-world",
150-
"dev",
150+
"homologacao",
151151
{
152152
"Ref": "AWS::Region"
153153
},
@@ -164,9 +164,9 @@
164164
"S3Bucket": {
165165
"Ref": "ServerlessDeploymentBucket"
166166
},
167-
"S3Key": "serverless/api-python-hello-world/dev/1606250373036-2020-11-24T20:39:33.036Z/api-python-hello-world.zip"
167+
"S3Key": "serverless/api-python-hello-world/homologacao/1606308726502-2020-11-25T12:52:06.502Z/api-python-hello-world.zip"
168168
},
169-
"FunctionName": "api-python-hello-world-dev-hello",
169+
"FunctionName": "api-python-hello-world-homologacao-hello",
170170
"Handler": "src/item.hello_world",
171171
"MemorySize": 256,
172172
"Role": {
@@ -182,20 +182,20 @@
182182
"HelloLogGroup"
183183
]
184184
},
185-
"HelloLambdaVersion17IOIygMGs2nmaA3r9vypDFb4y68JKXVJYQxmT6sU": {
185+
"HelloLambdaVersiontl1PaqUWQaUSV63k1OivjVUiGn2YxNU8rVBD67hdzS0": {
186186
"Type": "AWS::Lambda::Version",
187187
"DeletionPolicy": "Retain",
188188
"Properties": {
189189
"FunctionName": {
190190
"Ref": "HelloLambdaFunction"
191191
},
192-
"CodeSha256": "xUV5Bo8pL1R46jPSEfLDg6FHEMl6K0YNrTxoeX2D2BE="
192+
"CodeSha256": "/tharYWbigYLNY+e6E4mtpjAwxqbS7GB65Kwd9V0bUc="
193193
}
194194
},
195195
"ApiGatewayRestApi": {
196196
"Type": "AWS::ApiGateway::RestApi",
197197
"Properties": {
198-
"Name": "dev-api-python-hello-world",
198+
"Name": "homologacao-api-python-hello-world",
199199
"EndpointConfiguration": {
200200
"Types": [
201201
"EDGE"
@@ -393,13 +393,13 @@
393393
]
394394
}
395395
},
396-
"ApiGatewayDeployment1606250371399": {
396+
"ApiGatewayDeployment1606308724338": {
397397
"Type": "AWS::ApiGateway::Deployment",
398398
"Properties": {
399399
"RestApiId": {
400400
"Ref": "ApiGatewayRestApi"
401401
},
402-
"StageName": "dev"
402+
"StageName": "homologacao"
403403
},
404404
"DependsOn": [
405405
"ApiGatewayMethodApiPythonHelloDashworldGet"
@@ -409,32 +409,32 @@
409409
"Type": "AWS::ApiGateway::ApiKey",
410410
"Properties": {
411411
"Enabled": true,
412-
"Name": "myKey",
412+
"Name": "homologacao-myKey",
413413
"StageKeys": [
414414
{
415415
"RestApiId": {
416416
"Ref": "ApiGatewayRestApi"
417417
},
418-
"StageName": "dev"
418+
"StageName": "homologacao"
419419
}
420420
]
421421
},
422-
"DependsOn": "ApiGatewayDeployment1606250371399"
422+
"DependsOn": "ApiGatewayDeployment1606308724338"
423423
},
424424
"ApiGatewayUsagePlan": {
425425
"Type": "AWS::ApiGateway::UsagePlan",
426-
"DependsOn": "ApiGatewayDeployment1606250371399",
426+
"DependsOn": "ApiGatewayDeployment1606308724338",
427427
"Properties": {
428428
"ApiStages": [
429429
{
430430
"ApiId": {
431431
"Ref": "ApiGatewayRestApi"
432432
},
433-
"Stage": "dev"
433+
"Stage": "homologacao"
434434
}
435435
],
436-
"Description": "Usage plan for api-python-hello-world dev stage",
437-
"UsagePlanName": "api-python-hello-world-dev"
436+
"Description": "Usage plan for api-python-hello-world homologacao stage",
437+
"UsagePlanName": "api-python-hello-world-homologacao"
438438
}
439439
},
440440
"ApiGatewayUsagePlanKey1": {
@@ -496,7 +496,7 @@
496496
"HelloLambdaFunctionQualifiedArn": {
497497
"Description": "Current Lambda function version",
498498
"Value": {
499-
"Ref": "HelloLambdaVersion17IOIygMGs2nmaA3r9vypDFb4y68JKXVJYQxmT6sU"
499+
"Ref": "HelloLambdaVersiontl1PaqUWQaUSV63k1OivjVUiGn2YxNU8rVBD67hdzS0"
500500
}
501501
},
502502
"ServiceEndpoint": {
@@ -517,7 +517,7 @@
517517
{
518518
"Ref": "AWS::URLSuffix"
519519
},
520-
"/dev"
520+
"/homologacao"
521521
]
522522
]
523523
}
@@ -593,6 +593,9 @@
593593
},
594594
"vpc": {}
595595
},
596+
"custom": {
597+
"stage": "homologacao"
598+
},
596599
"pluginsData": {},
597600
"functions": {
598601
"hello": {
@@ -644,11 +647,11 @@
644647
}
645648
}
646649
],
647-
"name": "api-python-hello-world-dev-hello",
650+
"name": "api-python-hello-world-homologacao-hello",
648651
"package": {},
649652
"memory": 256,
650653
"vpc": {},
651-
"versionLogicalId": "HelloLambdaVersion17IOIygMGs2nmaA3r9vypDFb4y68JKXVJYQxmT6sU"
654+
"versionLogicalId": "HelloLambdaVersiontl1PaqUWQaUSV63k1OivjVUiGn2YxNU8rVBD67hdzS0"
652655
}
653656
},
654657
"configValidationMode": "warn",
@@ -658,6 +661,9 @@
658661
"service": {
659662
"$ref": "$[\"service\"][\"serviceObject\"]"
660663
},
664+
"custom": {
665+
"$ref": "$[\"service\"][\"custom\"]"
666+
},
661667
"provider": {
662668
"$ref": "$[\"service\"][\"provider\"]"
663669
},
@@ -669,7 +675,7 @@
669675
"artifact": "/media/tayron/HD Hitachi 320GB1/Desenvolvimento/npm-servless/serverless-api-python/.serverless/api-python-hello-world.zip"
670676
},
671677
"package": {
672-
"artifactDirectoryName": "serverless/api-python-hello-world/dev/1606250373036-2020-11-24T20:39:33.036Z",
678+
"artifactDirectoryName": "serverless/api-python-hello-world/homologacao/1606308726502-2020-11-25T12:52:06.502Z",
673679
"artifact": "api-python-hello-world.zip"
674680
}
675681
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ serverless config credentials \
2222

2323
#### Comando para realizar deploy:
2424

25+
Para fazer deploy e manter o stage padrão: **dev**
2526
```serverless deploy --aws-profile my-aws-profile```
2627

28+
Para fazer deploy e alterar o stage padrão: **dev** para **prod**
29+
```serverless deploy --aws-profile my-aws-profile --stage prod```
30+
2731
O resultado do comando será algo parecido com
2832
```
2933
....

serverless.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
service: api-python-hello-world
22

3+
custom:
4+
stage: ${opt:stage, self:provider.stage}
5+
36
provider:
47
name: aws
58
region: us-east-1
69
runtime: python3.7
710
stage: dev
811
apiKeys:
9-
- name: myKey
12+
- name: ${self:custom.stage}-myKey
1013

1114
functions:
1215
hello:
1316
handler: src/item.hello_world
14-
runtime: python3.7
17+
runtime: ${self:provider.runtime}
1518
memorySize: 256
1619
timeout: 20
1720
events:

0 commit comments

Comments
 (0)