Elffuss BraidHub

kikocis/ecs-apigateway-sample public

master · 23.0 KiBRawPermalink
1# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2# SPDX-License-Identifier: MIT
3
4AWSTemplateFormatVersion: '2010-09-09'
5
6Description: Demo of an AWS Fargate cluster hosting APIs exposed through API Gateway.
7
8Parameters:
9 EnvironmentName:
10 Type: String
11 Default: ecsapi-demo
12 Description: "A friendly environment name that will be used for namespacing all cluster resources. Example: staging, qa, or production"
13 PrivateDNSNamespaceName:
14 Type: String
15 Default: service
16 Description: "The private DNS name that identifies the name that you want to use to locate your resources"
17 MinContainersFoodstoreFoods:
18 Type: Number
19 Default: 3
20 Description: "Minimum number of ECS tasks per ECS service"
21 MaxContainersFoodstoreFoods:
22 Type: Number
23 Default: 30
24 Description: "Maximum number of ECS tasks per ECS service"
25 AutoScalingTargetValueFoodstoreFoods:
26 Type: Number
27 Default: 50
28 Description: "Target CPU utilizatio (%) for ECS services auto scaling"
29 MinContainersPetstorePets:
30 Type: Number
31 Default: 3
32 Description: "Minimum number of ECS tasks per ECS service"
33 MaxContainersPetstorePets:
34 Type: Number
35 Default: 30
36 Description: "Maximum number of ECS tasks per ECS service"
37 AutoScalingTargetValuePetstorePets:
38 Type: Number
39 Default: 50
40 Description: "Target CPU utilizatio (%) for ECS services auto scaling"
41
42Metadata:
43 AWS::CloudFormation::Interface:
44 ParameterGroups:
45 -
46 Label:
47 default: "Generic"
48 Parameters:
49 - EnvironmentName
50 - PrivateDNSNamespaceName
51 -
52 Label:
53 default: "FoodstoreFoods Service"
54 Parameters:
55 - MinContainersFoodstoreFoods
56 - MaxContainersFoodstoreFoods
57 - AutoScalingTargetValueFoodstoreFoods
58 -
59 Label:
60 default: "PetstorePets Service"
61 Parameters:
62 - MinContainersPetstorePets
63 - MaxContainersPetstorePets
64 - AutoScalingTargetValuePetstorePets
65
66Mappings:
67 SubnetConfig:
68 VPC:
69 CIDR: '10.0.0.0/16'
70 PublicOne:
71 CIDR: '10.0.0.0/24'
72 PublicTwo:
73 CIDR: '10.0.1.0/24'
74 PublicThree:
75 CIDR: '10.0.2.0/24'
76 PrivateOne:
77 CIDR: '10.0.100.0/24'
78 PrivateTwo:
79 CIDR: '10.0.101.0/24'
80 PrivateThree:
81 CIDR: '10.0.102.0/24'
82
83Resources:
84
85 DynamoDBTableFoodstoreFoods:
86 Type: AWS::DynamoDB::Table
87 Properties:
88 BillingMode: PAY_PER_REQUEST
89 AttributeDefinitions:
90 - AttributeName: foodId
91 AttributeType: S
92 KeySchema:
93 - AttributeName: foodId
94 KeyType: HASH
95
96 DynamoDBTablePetstorePets:
97 Type: AWS::DynamoDB::Table
98 Properties:
99 BillingMode: PAY_PER_REQUEST
100 AttributeDefinitions:
101 - AttributeName: petId
102 AttributeType: S
103 KeySchema:
104 - AttributeName: petId
105 KeyType: HASH
106
107 VPC:
108 Type: AWS::EC2::VPC
109 Properties:
110 EnableDnsSupport: true
111 EnableDnsHostnames: true
112 CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR']
113
114 PublicSubnetOne:
115 Type: AWS::EC2::Subnet
116 Properties:
117 AvailabilityZone: !Select
118 - 0
119 - Fn::GetAZs: !Ref 'AWS::Region'
120 VpcId: !Ref 'VPC'
121 CidrBlock: !FindInMap ['SubnetConfig', 'PublicOne', 'CIDR']
122 MapPublicIpOnLaunch: true
123 PublicSubnetTwo:
124 Type: AWS::EC2::Subnet
125 Properties:
126 AvailabilityZone: !Select
127 - 1
128 - Fn::GetAZs: !Ref 'AWS::Region'
129 VpcId: !Ref 'VPC'
130 CidrBlock: !FindInMap ['SubnetConfig', 'PublicTwo', 'CIDR']
131 MapPublicIpOnLaunch: true
132 PublicSubnetThree:
133 Type: AWS::EC2::Subnet
134 Properties:
135 AvailabilityZone: !Select
136 - 2
137 - Fn::GetAZs: !Ref 'AWS::Region'
138 VpcId: !Ref 'VPC'
139 CidrBlock: !FindInMap ['SubnetConfig', 'PublicThree', 'CIDR']
140 MapPublicIpOnLaunch: true
141
142 PrivateSubnetOne:
143 Type: AWS::EC2::Subnet
144 Properties:
145 AvailabilityZone: !Select
146 - 0
147 - Fn::GetAZs: !Ref 'AWS::Region'
148 VpcId: !Ref 'VPC'
149 CidrBlock: !FindInMap ['SubnetConfig', 'PrivateOne', 'CIDR']
150 PrivateSubnetTwo:
151 Type: AWS::EC2::Subnet
152 Properties:
153 AvailabilityZone: !Select
154 - 1
155 - Fn::GetAZs: !Ref 'AWS::Region'
156 VpcId: !Ref 'VPC'
157 CidrBlock: !FindInMap ['SubnetConfig', 'PrivateTwo', 'CIDR']
158 PrivateSubnetThree:
159 Type: AWS::EC2::Subnet
160 Properties:
161 AvailabilityZone: !Select
162 - 2
163 - Fn::GetAZs: !Ref 'AWS::Region'
164 VpcId: !Ref 'VPC'
165 CidrBlock: !FindInMap ['SubnetConfig', 'PrivateThree', 'CIDR']
166
167 InternetGateway:
168 Type: AWS::EC2::InternetGateway
169 GatewayAttachement:
170 Type: AWS::EC2::VPCGatewayAttachment
171 Properties:
172 VpcId: !Ref 'VPC'
173 InternetGatewayId: !Ref 'InternetGateway'
174 PublicRouteTable:
175 Type: AWS::EC2::RouteTable
176 Properties:
177 VpcId: !Ref 'VPC'
178 PublicRoute:
179 Type: AWS::EC2::Route
180 DependsOn: GatewayAttachement
181 Properties:
182 RouteTableId: !Ref 'PublicRouteTable'
183 DestinationCidrBlock: '0.0.0.0/0'
184 GatewayId: !Ref 'InternetGateway'
185 PublicSubnetOneRouteTableAssociation:
186 Type: AWS::EC2::SubnetRouteTableAssociation
187 Properties:
188 SubnetId: !Ref PublicSubnetOne
189 RouteTableId: !Ref PublicRouteTable
190 PublicSubnetTwoRouteTableAssociation:
191 Type: AWS::EC2::SubnetRouteTableAssociation
192 Properties:
193 SubnetId: !Ref PublicSubnetTwo
194 RouteTableId: !Ref PublicRouteTable
195 PublicSubnetThreeRouteTableAssociation:
196 Type: AWS::EC2::SubnetRouteTableAssociation
197 Properties:
198 SubnetId: !Ref PublicSubnetThree
199 RouteTableId: !Ref PublicRouteTable
200
201 NatGatewayOneAttachment:
202 Type: AWS::EC2::EIP
203 DependsOn: GatewayAttachement
204 Properties:
205 Domain: vpc
206 NatGatewayTwoAttachment:
207 Type: AWS::EC2::EIP
208 DependsOn: GatewayAttachement
209 Properties:
210 Domain: vpc
211 NatGatewayThreeAttachment:
212 Type: AWS::EC2::EIP
213 DependsOn: GatewayAttachement
214 Properties:
215 Domain: vpc
216 NatGatewayOne:
217 Type: AWS::EC2::NatGateway
218 Properties:
219 AllocationId: !GetAtt NatGatewayOneAttachment.AllocationId
220 SubnetId: !Ref PublicSubnetOne
221 NatGatewayTwo:
222 Type: AWS::EC2::NatGateway
223 Properties:
224 AllocationId: !GetAtt NatGatewayTwoAttachment.AllocationId
225 SubnetId: !Ref PublicSubnetTwo
226 NatGatewayThree:
227 Type: AWS::EC2::NatGateway
228 Properties:
229 AllocationId: !GetAtt NatGatewayThreeAttachment.AllocationId
230 SubnetId: !Ref PublicSubnetThree
231 PrivateRouteTableOne:
232 Type: AWS::EC2::RouteTable
233 Properties:
234 VpcId: !Ref 'VPC'
235 PrivateRouteOne:
236 Type: AWS::EC2::Route
237 Properties:
238 RouteTableId: !Ref PrivateRouteTableOne
239 DestinationCidrBlock: 0.0.0.0/0
240 NatGatewayId: !Ref NatGatewayOne
241 PrivateRouteTableOneAssociation:
242 Type: AWS::EC2::SubnetRouteTableAssociation
243 Properties:
244 RouteTableId: !Ref PrivateRouteTableOne
245 SubnetId: !Ref PrivateSubnetOne
246 PrivateRouteTableTwo:
247 Type: AWS::EC2::RouteTable
248 Properties:
249 VpcId: !Ref 'VPC'
250 PrivateRouteTwo:
251 Type: AWS::EC2::Route
252 Properties:
253 RouteTableId: !Ref PrivateRouteTableTwo
254 DestinationCidrBlock: 0.0.0.0/0
255 NatGatewayId: !Ref NatGatewayTwo
256 PrivateRouteTableTwoAssociation:
257 Type: AWS::EC2::SubnetRouteTableAssociation
258 Properties:
259 RouteTableId: !Ref PrivateRouteTableTwo
260 SubnetId: !Ref PrivateSubnetTwo
261 PrivateRouteTableThree:
262 Type: AWS::EC2::RouteTable
263 Properties:
264 VpcId: !Ref 'VPC'
265 PrivateRouteThree:
266 Type: AWS::EC2::Route
267 Properties:
268 RouteTableId: !Ref PrivateRouteTableThree
269 DestinationCidrBlock: 0.0.0.0/0
270 NatGatewayId: !Ref NatGatewayThree
271 PrivateRouteTableThreeAssociation:
272 Type: AWS::EC2::SubnetRouteTableAssociation
273 Properties:
274 RouteTableId: !Ref PrivateRouteTableThree
275 SubnetId: !Ref PrivateSubnetThree
276
277 DynamoDBEndpoint:
278 Type: AWS::EC2::VPCEndpoint
279 Properties:
280 PolicyDocument:
281 Version: "2012-10-17"
282 Statement:
283 - Effect: Allow
284 Action: "*"
285 Principal: "*"
286 Resource: "*"
287 RouteTableIds:
288 - !Ref 'PrivateRouteTableOne'
289 - !Ref 'PrivateRouteTableTwo'
290 - !Ref 'PrivateRouteTableThree'
291 ServiceName: !Sub com.amazonaws.${AWS::Region}.dynamodb
292 VpcId: !Ref 'VPC'
293
294 ECSCluster:
295 Type: AWS::ECS::Cluster
296
297 ContainerSecurityGroup:
298 Type: AWS::EC2::SecurityGroup
299 Properties:
300 GroupDescription: Access to the Fargate containers
301 VpcId: !Ref 'VPC'
302
303 ContainerSecurityGroupSelfIngress:
304 Type: AWS::EC2::SecurityGroupIngress
305 Properties:
306 GroupId: !Ref ContainerSecurityGroup
307 SourceSecurityGroupId: !Ref ContainerSecurityGroup
308 IpProtocol: tcp
309 FromPort: 8080
310 ToPort: 8080
311
312 AutoScalingRole:
313 Type: AWS::IAM::Role
314 Properties:
315 AssumeRolePolicyDocument:
316 Statement:
317 - Effect: Allow
318 Principal:
319 Service: ecs-tasks.amazonaws.com
320 Action: 'sts:AssumeRole'
321 ManagedPolicyArns:
322 - 'arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceAutoscaleRole'
323
324 ECSRole:
325 Type: AWS::IAM::Role
326 Properties:
327 AssumeRolePolicyDocument:
328 Statement:
329 - Effect: Allow
330 Principal:
331 Service: [ecs.amazonaws.com]
332 Action: ['sts:AssumeRole']
333 Path: /
334 Policies:
335 - PolicyName: ecs-service
336 PolicyDocument:
337 Statement:
338 - Effect: Allow
339 Action:
340 - 'ec2:AttachNetworkInterface'
341 - 'ec2:CreateNetworkInterface'
342 - 'ec2:CreateNetworkInterfacePermission'
343 - 'ec2:DeleteNetworkInterface'
344 - 'ec2:DeleteNetworkInterfacePermission'
345 - 'ec2:Describe*'
346 - 'ec2:DetachNetworkInterface'
347
348 - 'elasticloadbalancing:DeregisterInstancesFromLoadBalancer'
349 - 'elasticloadbalancing:DeregisterTargets'
350 - 'elasticloadbalancing:Describe*'
351 - 'elasticloadbalancing:RegisterInstancesWithLoadBalancer'
352 - 'elasticloadbalancing:RegisterTargets'
353 Resource: '*'
354
355 ECSTaskExecutionRole:
356 Type: AWS::IAM::Role
357 Properties:
358 AssumeRolePolicyDocument:
359 Statement:
360 - Effect: Allow
361 Principal:
362 Service: [ecs-tasks.amazonaws.com]
363 Action: ['sts:AssumeRole']
364 Path: /
365 Policies:
366 - PolicyName: AmazonECSTaskExecutionRolePolicy
367 PolicyDocument:
368 Statement:
369 - Effect: Allow
370 Action:
371 # Allow the ECS Tasks to download images from ECR
372 - 'ecr:GetAuthorizationToken'
373 - 'ecr:BatchCheckLayerAvailability'
374 - 'ecr:GetDownloadUrlForLayer'
375 - 'ecr:BatchGetImage'
376
377 # Allow the ECS tasks to upload logs to CloudWatch
378 - 'logs:CreateLogStream'
379 - 'logs:PutLogEvents'
380 Resource: '*'
381
382 PrivateDNSNamespace:
383 Type: 'AWS::ServiceDiscovery::PrivateDnsNamespace'
384 Properties:
385 Vpc: !Ref VPC
386 Name: !Ref PrivateDNSNamespaceName
387
388 ServiceDiscoveryServiceFoodstoreFoods:
389 Type: 'AWS::ServiceDiscovery::Service'
390 Properties:
391 DnsConfig:
392 DnsRecords:
393 - Type: SRV
394 TTL: 60
395 NamespaceId: !Ref PrivateDNSNamespace
396 HealthCheckCustomConfig:
397 FailureThreshold: 1
398 Name: 'foods.foodstore'
399
400 ServiceDiscoveryServicePetstorePets:
401 Type: 'AWS::ServiceDiscovery::Service'
402 Properties:
403 DnsConfig:
404 DnsRecords:
405 - Type: SRV
406 TTL: 60
407 NamespaceId: !Ref PrivateDNSNamespace
408 HealthCheckCustomConfig:
409 FailureThreshold: 1
410 Name: 'pets.petstore'
411
412 TaskRoleFoodstoreFoods:
413 Type: AWS::IAM::Role
414 Properties:
415 AssumeRolePolicyDocument:
416 Statement:
417 - Effect: Allow
418 Principal:
419 Service: ecs-tasks.amazonaws.com
420 Action: 'sts:AssumeRole'
421 Policies:
422 - PolicyName: dynamodb-table-access
423 PolicyDocument:
424 Statement:
425 - Effect: Allow
426 Action:
427 - dynamodb:BatchGet*
428 - dynamodb:DescribeStream
429 - dynamodb:DescribeTable
430 - dynamodb:Get*
431 - dynamodb:Query
432 - dynamodb:Scan
433 - dynamodb:BatchWrite*
434 - dynamodb:CreateTable
435 - dynamodb:Delete*
436 - dynamodb:Update*
437 - dynamodb:PutItem
438 Resource: !GetAtt DynamoDBTableFoodstoreFoods.Arn
439
440 TaskRolePetstorePets:
441 Type: AWS::IAM::Role
442 Properties:
443 AssumeRolePolicyDocument:
444 Statement:
445 - Effect: Allow
446 Principal:
447 Service: ecs-tasks.amazonaws.com
448 Action: 'sts:AssumeRole'
449 Policies:
450 - PolicyName: dynamodb-table-access
451 PolicyDocument:
452 Statement:
453 - Effect: Allow
454 Action:
455 - dynamodb:BatchGet*
456 - dynamodb:DescribeStream
457 - dynamodb:DescribeTable
458 - dynamodb:Get*
459 - dynamodb:Query
460 - dynamodb:Scan
461 - dynamodb:BatchWrite*
462 - dynamodb:CreateTable
463 - dynamodb:Delete*
464 - dynamodb:Update*
465 - dynamodb:PutItem
466 Resource: !GetAtt DynamoDBTablePetstorePets.Arn
467
468 TaskDefinitionFoodstoreFoods:
469 Type: 'AWS::ECS::TaskDefinition'
470 Properties:
471 TaskRoleArn: !GetAtt TaskRoleFoodstoreFoods.Arn
472 RequiresCompatibilities:
473 - FARGATE
474 ContainerDefinitions:
475 - Name: 'FoodstoreFoods'
476 Image: 'simonepomata/ecsapi-demo-foodstore:latest'
477 Essential: true
478 PortMappings:
479 - ContainerPort: 8080
480 Protocol: tcp
481 Environment:
482 - Name: DynamoDBTable
483 Value: !Ref DynamoDBTableFoodstoreFoods
484 NetworkMode: awsvpc
485 Memory: '512'
486 Cpu: '256'
487
488 TaskDefinitionPetstorePets:
489 Type: 'AWS::ECS::TaskDefinition'
490 Properties:
491 TaskRoleArn: !GetAtt TaskRolePetstorePets.Arn
492 RequiresCompatibilities:
493 - FARGATE
494 ContainerDefinitions:
495 - Name: 'PetstorePets'
496 Image: 'simonepomata/ecsapi-demo-petstore:latest'
497 Essential: true
498 PortMappings:
499 - ContainerPort: 8080
500 Protocol: tcp
501 Environment:
502 - Name: DynamoDBTable
503 Value: !Ref DynamoDBTablePetstorePets
504 NetworkMode: awsvpc
505 Memory: '512'
506 Cpu: '256'
507
508 ServiceFoodstoreFoods:
509 Type: AWS::ECS::Service
510 DependsOn:
511 - PrivateRouteOne
512 - PrivateRouteTwo
513 - PrivateRouteThree
514 Properties:
515 Cluster: !Ref ECSCluster
516 TaskDefinition: !Ref TaskDefinitionFoodstoreFoods
517 LaunchType: FARGATE
518 DesiredCount: 3
519 ServiceRegistries:
520 - RegistryArn: !GetAtt ServiceDiscoveryServiceFoodstoreFoods.Arn
521 Port: 8080
522 NetworkConfiguration:
523 AwsvpcConfiguration:
524 AssignPublicIp: DISABLED
525 Subnets:
526 - !Ref PrivateSubnetOne
527 - !Ref PrivateSubnetTwo
528 - !Ref PrivateSubnetThree
529 SecurityGroups:
530 - !Ref ContainerSecurityGroup
531
532 ServicePetstorePets:
533 Type: AWS::ECS::Service
534 DependsOn:
535 - PrivateRouteOne
536 - PrivateRouteTwo
537 - PrivateRouteThree
538 Properties:
539 Cluster: !Ref ECSCluster
540 TaskDefinition: !Ref TaskDefinitionPetstorePets
541 LaunchType: FARGATE
542 DesiredCount: 3
543 ServiceRegistries:
544 - RegistryArn: !GetAtt ServiceDiscoveryServicePetstorePets.Arn
545 Port: 8080
546 NetworkConfiguration:
547 AwsvpcConfiguration:
548 AssignPublicIp: DISABLED
549 Subnets:
550 - !Ref PrivateSubnetOne
551 - !Ref PrivateSubnetTwo
552 - !Ref PrivateSubnetThree
553 SecurityGroups:
554 - !Ref ContainerSecurityGroup
555
556 AutoScalingTargetFoodstoreFoods:
557 Type: AWS::ApplicationAutoScaling::ScalableTarget
558 Properties:
559 MinCapacity: !Ref MinContainersFoodstoreFoods
560 MaxCapacity: !Ref MaxContainersFoodstoreFoods
561 ResourceId: !Join ['/', [service, !Ref ECSCluster, !GetAtt ServiceFoodstoreFoods.Name]]
562 ScalableDimension: ecs:service:DesiredCount
563 ServiceNamespace: ecs
564 RoleARN: !GetAtt AutoScalingRole.Arn
565
566 AutoScalingTargetPetstorePets:
567 Type: AWS::ApplicationAutoScaling::ScalableTarget
568 Properties:
569 MinCapacity: !Ref MinContainersPetstorePets
570 MaxCapacity: !Ref MaxContainersPetstorePets
571 ResourceId: !Join ['/', [service, !Ref ECSCluster, !GetAtt ServicePetstorePets.Name]]
572 ScalableDimension: ecs:service:DesiredCount
573 ServiceNamespace: ecs
574 RoleARN: !GetAtt AutoScalingRole.Arn
575
576 AutoScalingPolicyFoodstoreFoods:
577 Type: AWS::ApplicationAutoScaling::ScalingPolicy
578 Properties:
579 PolicyName: !Join ['', [!GetAtt ServiceFoodstoreFoods.Name, '-AutoScalingPolicy']]
580 PolicyType: TargetTrackingScaling
581 ScalingTargetId: !Ref AutoScalingTargetFoodstoreFoods
582 TargetTrackingScalingPolicyConfiguration:
583 PredefinedMetricSpecification:
584 PredefinedMetricType: ECSServiceAverageCPUUtilization
585 TargetValue: !Ref AutoScalingTargetValueFoodstoreFoods
586
587 AutoScalingPolicyPetstorePets:
588 Type: AWS::ApplicationAutoScaling::ScalingPolicy
589 Properties:
590 PolicyName: !Join ['', [!GetAtt ServicePetstorePets.Name, '-AutoScalingPolicy']]
591 PolicyType: TargetTrackingScaling
592 ScalingTargetId: !Ref AutoScalingTargetPetstorePets
593 TargetTrackingScalingPolicyConfiguration:
594 PredefinedMetricSpecification:
595 PredefinedMetricType: ECSServiceAverageCPUUtilization
596 TargetValue: !Ref AutoScalingTargetValuePetstorePets
597
598 HttpApiVPCLink:
599 Type: AWS::ApiGatewayV2::VpcLink
600 Properties:
601 Name: !Ref EnvironmentName
602 SecurityGroupIds:
603 - !Ref ContainerSecurityGroup
604 SubnetIds:
605 - !Ref PrivateSubnetOne
606 - !Ref PrivateSubnetTwo
607 - !Ref PrivateSubnetThree
608
609 UserPool:
610 Type: AWS::Cognito::UserPool
611 Properties:
612 UsernameAttributes:
613 - email
614 AutoVerifiedAttributes:
615 - email
616
617 UserPoolClient:
618 Type: "AWS::Cognito::UserPoolClient"
619 Properties:
620 UserPoolId: !Ref UserPool
621 GenerateSecret: false
622 SupportedIdentityProviders:
623 - COGNITO
624 PreventUserExistenceErrors: ENABLED
625
626 HttpApi:
627 Type: AWS::ApiGatewayV2::Api
628 Properties:
629 Body:
630 openapi: "3.0.1"
631 info:
632 title: !Ref EnvironmentName
633 components:
634 securitySchemes:
635 my-authorizer:
636 type: oauth2
637 flows: {}
638 x-amazon-apigateway-authorizer:
639 identitySource: "$request.header.Authorization"
640 jwtConfiguration:
641 audience:
642 - !Ref 'UserPoolClient'
643 issuer: !GetAtt 'UserPool.ProviderURL'
644 type: jwt
645 paths:
646 /foodstore/foods/{foodId}:
647 get:
648 responses:
649 default:
650 description: "Default response for GET /foodstore/foods/{foodId}"
651 x-amazon-apigateway-integration:
652 payloadFormatVersion: "1.0"
653 connectionId: !Ref HttpApiVPCLink
654 type: "http_proxy"
655 httpMethod: "ANY"
656 uri: !GetAtt ServiceDiscoveryServiceFoodstoreFoods.Arn
657 connectionType: "VPC_LINK"
658 put:
659 responses:
660 default:
661 description: "Default response for PUT /foodstore/foods/{foodId}"
662 security:
663 - my-authorizer: []
664 x-amazon-apigateway-integration:
665 payloadFormatVersion: "1.0"
666 connectionId: !Ref HttpApiVPCLink
667 type: "http_proxy"
668 httpMethod: "ANY"
669 uri: !GetAtt ServiceDiscoveryServiceFoodstoreFoods.Arn
670 connectionType: "VPC_LINK"
671 /petstore/pets/{petId}:
672 get:
673 responses:
674 default:
675 description: "Default response for GET /petstore/pets/{petId}"
676 x-amazon-apigateway-integration:
677 payloadFormatVersion: "1.0"
678 connectionId: !Ref HttpApiVPCLink
679 type: "http_proxy"
680 httpMethod: "ANY"
681 uri: !GetAtt ServiceDiscoveryServicePetstorePets.Arn
682 connectionType: "VPC_LINK"
683 put:
684 responses:
685 default:
686 description: "Default response for PUT /petstore/pets/{petId}"
687 security:
688 - my-authorizer: []
689 x-amazon-apigateway-integration:
690 payloadFormatVersion: "1.0"
691 connectionId: !Ref HttpApiVPCLink
692 type: "http_proxy"
693 httpMethod: "ANY"
694 uri: !GetAtt ServiceDiscoveryServicePetstorePets.Arn
695 connectionType: "VPC_LINK"
696 x-amazon-apigateway-cors:
697 # This is a Test client web app that invokes the API, used in the blog post, for demostration purposes only.
698 # In production, make sure that you do NOT allow any untrusted origin.
699 allowOrigins:
700 - 'https://master.d34am23lsz3nvz.amplifyapp.com'
701 allowHeaders:
702 - '*'
703 allowMethods:
704 - 'PUT'
705 - 'GET'
706 x-amazon-apigateway-importexport-version: "1.0"
707
708 HttpApiStage:
709 Type: 'AWS::ApiGatewayV2::Stage'
710 Properties:
711 StageName: '$default'
712 ApiId: !Ref 'HttpApi'
713 AutoDeploy: true
714
715Outputs:
716 APITestPage:
717 Description: The URL of the sample web app client, used to test the sample API
718 Value: !Join
719 - ''
720 - - "https://master.d34am23lsz3nvz.amplifyapp.com/?stackregion="
721 - !Ref 'AWS::Region'
722 - "&stackhttpapi="
723 - !Ref 'HttpApi'
724 - "&stackuserpool="
725 - !Ref 'UserPool'
726 - "&stackuserpoolclient="
727 - !Ref 'UserPoolClient'
728 APIInvokeURL:
729 Description: Invoke URL for the HTTP API
730 Value: !Sub 'https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com'
731 APIInvokeURLFoodstoreFoods:
732 Description: Invoke URL for the HTTP API for the service Foodstore Foods
733 Value: !Sub 'https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com/foodstore/foods/{foodId}'
734 APIInvokeURLPetstorePets:
735 Description: Invoke URL for the HTTP API for the service Petstore Pets
736 Value: !Sub 'https://${HttpApi}.execute-api.${AWS::Region}.amazonaws.com/petstore/pets/{petId}'
737 APIId:
738 Description: The ID of the HTTP API
739 Value: !Ref 'HttpApi'
740 ECSClusterName:
741 Description: The name of the ECS cluster
742 Value: !Ref 'ECSCluster'
743 VpcId:
744 Description: The ID of the VPC that this stack is deployed in
745 Value: !Ref 'VPC'
746 ContainerSecurityGroup:
747 Description: A security group used to allow Fargate containers to receive traffic
748 Value: !Ref 'ContainerSecurityGroup'
749 PrivateDNSNamespace:
750 Description: The ID of the private DNS namespace.
751 Value: !Ref 'PrivateDNSNamespace'