File tree Expand file tree Collapse file tree 7 files changed +124
-0
lines changed
cloudformation-compose-service
traditional-compose-service Expand file tree Collapse file tree 7 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ AWSTemplateFormatVersion : " 2010-09-09"
2
+
3
+ Resources :
4
+ SharedTable :
5
+ Type : " AWS::DynamoDB::Table"
6
+ Properties :
7
+ TableName : ${param:tableNamePrefix}-${param:stageLabel}
8
+ AttributeDefinitions :
9
+ - AttributeName : " Id"
10
+ AttributeType : " S"
11
+ KeySchema :
12
+ - AttributeName : " Id"
13
+ KeyType : " HASH"
14
+ ProvisionedThroughput :
15
+ ReadCapacityUnits : 5
16
+ WriteCapacityUnits : 5
17
+
18
+ Outputs :
19
+ TableName :
20
+ Value : !Ref SharedTable
Original file line number Diff line number Diff line change
1
+ exports . handler = async ( event ) => {
2
+ return {
3
+ tableName : process . env . TABLE_NAME ,
4
+ stageLabel : process . env . STAGE_LABEL ,
5
+ service : "sam-compose-service" ,
6
+ message :
7
+ "This is the staged table name that was constructed using the compose outputs and params" ,
8
+ } ;
9
+ } ;
Original file line number Diff line number Diff line change
1
+ version = 0.1
2
+
3
+ [default ]
4
+ [default .global .parameters ]
5
+ stack_name = " sam-compose-service-example"
Original file line number Diff line number Diff line change
1
+ AWSTemplateFormatVersion : " 2010-09-09"
2
+ Transform : AWS::Serverless-2016-10-31
3
+ Description : >
4
+ sam-app
5
+
6
+ Sample SAM Template for sam-app
7
+
8
+ Globals :
9
+ Function :
10
+ Timeout : 3
11
+ MemorySize : 128
12
+
13
+ Resources :
14
+ HelloWorldFunction :
15
+ Type : AWS::Serverless::Function
16
+ Properties :
17
+ Handler : handler.handler
18
+ Runtime : nodejs20.x
19
+ Environment :
20
+ Variables :
21
+ TABLE_NAME : ${param:tableName}
22
+ STAGE_LABEL : ${param:stageLabel}
23
+ Architectures :
24
+ - x86_64
25
+ Events :
26
+ Api :
27
+ Type : HttpApi
28
+ Properties :
29
+ Path : /
30
+ Method : GET
31
+
32
+ Outputs :
33
+ Endpoint :
34
+ Value : !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com"
Original file line number Diff line number Diff line change
1
+ # This example shows how to use Serverless Compose
2
+ # to compose 3 services together:
3
+ # - A CloudFormation service
4
+ # - A traditional Serverless Framework service
5
+ # - A SAM service
6
+ # It specifically shows how to pass parameters between services
7
+ # and how to reference outputs from one service in another service.
8
+
9
+ stages :
10
+ default :
11
+ params :
12
+ stageLabel : " testing"
13
+ prod :
14
+ params :
15
+ stageLabel : " production"
16
+
17
+ services :
18
+ cloudformation-compose-service :
19
+ path : cloudformation-compose-service
20
+ params :
21
+ tableNamePrefix : compose-shared-table
22
+
23
+ traditional-compose-service :
24
+ path : traditional-compose-service
25
+ params :
26
+ tableName : ${cloudformation-compose-service.TableName}
27
+
28
+ sam-compose-service :
29
+ path : sam-compose-service
30
+ params :
31
+ tableName : ${cloudformation-compose-service.TableName}
Original file line number Diff line number Diff line change
1
+ exports . handler = async ( event ) => {
2
+ return {
3
+ tableName : process . env . TABLE_NAME ,
4
+ stageLabel : process . env . STAGE_LABEL ,
5
+ service : "traditional-compose-service" ,
6
+ message :
7
+ "This is the staged table name that was constructed using the compose outputs and params" ,
8
+ } ;
9
+ } ;
Original file line number Diff line number Diff line change
1
+ service : traditional-compose-service
2
+
3
+ provider :
4
+ name : aws
5
+ runtime : nodejs20.x
6
+
7
+ functions :
8
+ hello :
9
+ handler : handler.handler
10
+ events :
11
+ - httpApi :
12
+ path : /
13
+ method : get
14
+ environment :
15
+ TABLE_NAME : ${param:tableName}
16
+ STAGE_LABEL : ${param:stageLabel}
You can’t perform that action at this time.
0 commit comments