Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions walkthroughs/howto-servicediscovery-cloudmap/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Parameters:
Type: String
Description: Envoy container image

ColorTellerImage:
ColorTellerBackendImage:
Type: String
Description: Color Teller container image
Description: Color Teller Backend container image

ColorGatewayImage:
ColorTellerFrontendImage:
Type: String
Description: Color Gateway container image
Description: Color Teller Frontend container image

LaunchType:
Type: String
Expand Down Expand Up @@ -85,10 +85,10 @@ Resources:
Fn::ImportValue:
!Sub "${AWS::StackName}-vpc:VPC"

ColorTellerServiceRegistry:
ColorTellerBackendServiceRegistry:
Type: AWS::ServiceDiscovery::Service
Properties:
Name: 'colorteller'
Name: 'colortellerbackend'
DnsConfig:
NamespaceId: !GetAtt 'CloudMapNamespace.Id'
DnsRecords:
Expand All @@ -97,10 +97,10 @@ Resources:
HealthCheckCustomConfig:
FailureThreshold: 1

ColorGatewayServiceRegistry:
ColorTellerFrontendServiceRegistry:
Type: AWS::ServiceDiscovery::Service
Properties:
Name: 'colorgateway'
Name: 'colortellerfrontend'
DnsConfig:
NamespaceId: !GetAtt 'CloudMapNamespace.Id'
DnsRecords:
Expand Down Expand Up @@ -180,12 +180,12 @@ Resources:
ListenerArn: !Ref PublicLoadBalancerListener
Priority: 1

ColorGatewayTaskDefinition:
ColorTellerFrontendTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
RequiresCompatibilities:
- !Ref LaunchType
Family: 'colorgateway'
Family: 'colortellerfrontend'
NetworkMode: 'awsvpc'
Cpu: 256
Memory: 512
Expand All @@ -207,7 +207,7 @@ Resources:
Value: '169.254.170.2,169.254.169.254'
ContainerDefinitions:
- Name: 'app'
Image: !Ref ColorGatewayImage
Image: !Ref ColorTellerFrontendImage
Essential: true
DependsOn:
- ContainerName: "envoy"
Expand All @@ -217,15 +217,15 @@ Resources:
Options:
awslogs-group: !Sub '${AWS::StackName}-log-group'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'colorgateway'
awslogs-stream-prefix: 'colortellerfrontend'
PortMappings:
- ContainerPort: 9080
Protocol: 'tcp'
Environment:
- Name: "SERVER_PORT"
Value: "9080"
- Name: "COLOR_TELLER_ENDPOINT"
Value: !Sub "colorteller.${AWS::StackName}-mesh.local:9080"
Value: !Sub "colortellerbackend.${AWS::StackName}-mesh.local:9080"
- Name: "TCP_ECHO_ENDPOINT"
Value: ""
- Name: "STAGE"
Expand Down Expand Up @@ -257,10 +257,10 @@ Resources:
Options:
awslogs-group: !Sub '${AWS::StackName}-log-group'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'colorgateway'
awslogs-stream-prefix: 'colortellerfrontend'
Environment:
- Name: 'APPMESH_VIRTUAL_NODE_NAME'
Value: !Sub 'mesh/${AWS::StackName}-mesh/virtualNode/colorgateway-node'
Value: !Sub 'mesh/${AWS::StackName}-mesh/virtualNode/colortellerfrontend-node'
- Name: 'ENVOY_LOG_LEVEL'
Value: 'debug'

Expand Down Expand Up @@ -291,7 +291,7 @@ Resources:
Value: '169.254.170.2,169.254.169.254'
ContainerDefinitions:
- Name: 'app'
Image: !Ref ColorTellerImage
Image: !Ref ColorTellerBackendImage
Essential: true
DependsOn:
- ContainerName: "envoy"
Expand Down Expand Up @@ -373,7 +373,7 @@ Resources:
Value: '169.254.170.2,169.254.169.254'
ContainerDefinitions:
- Name: 'app'
Image: !Ref ColorTellerImage
Image: !Ref ColorTellerBackendImage
Essential: true
DependsOn:
- ContainerName: "envoy"
Expand Down Expand Up @@ -428,7 +428,7 @@ Resources:
- Name: 'ENVOY_LOG_LEVEL'
Value: 'debug'

ColorGatewayService:
ColorTellerFrontendService:
Type: AWS::ECS::Service
DependsOn:
- WebLoadBalancerRule
Expand All @@ -440,7 +440,7 @@ Resources:
DesiredCount: 1
LaunchType: !Ref LaunchType
ServiceRegistries:
- RegistryArn: !GetAtt 'ColorGatewayServiceRegistry.Arn'
- RegistryArn: !GetAtt 'ColorTellerFrontendServiceRegistry.Arn'
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
Expand All @@ -451,7 +451,7 @@ Resources:
!Sub '${AWS::StackName}-vpc:PrivateSubnet1'
- Fn::ImportValue:
!Sub '${AWS::StackName}-vpc:PrivateSubnet2'
TaskDefinition: !Ref ColorGatewayTaskDefinition
TaskDefinition: !Ref ColorTellerFrontendTaskDefinition
LoadBalancers:
- ContainerName: app
ContainerPort: 9080
Expand All @@ -467,7 +467,7 @@ Resources:
DesiredCount: 1
LaunchType: !Ref LaunchType
ServiceRegistries:
- RegistryArn: !GetAtt 'ColorTellerServiceRegistry.Arn'
- RegistryArn: !GetAtt 'ColorTellerBackendServiceRegistry.Arn'
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
Expand All @@ -490,7 +490,7 @@ Resources:
DesiredCount: 1
LaunchType: !Ref LaunchType
ServiceRegistries:
- RegistryArn: !GetAtt 'ColorTellerServiceRegistry.Arn'
- RegistryArn: !GetAtt 'ColorTellerBackendServiceRegistry.Arn'
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
Expand All @@ -504,8 +504,8 @@ Resources:
TaskDefinition: !Ref GreenColorTellerTaskDefinition

Outputs:
ColorGatewayEndpoint:
Description: 'Public endpoint for Color Gateway service'
ColorTellerFrontendEndpoint:
Description: 'Public endpoint for Color Teller Frontend service'
Value: !Join ['', ['http://', !GetAtt 'PublicLoadBalancer.DNSName']]
Export:
Name: !Sub '${AWS::StackName}:ColorGatewayEndpoint'
Name: !Sub '${AWS::StackName}:ColorTellerFrontendEndpoint'
8 changes: 4 additions & 4 deletions walkthroughs/howto-servicediscovery-cloudmap/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
APP_DIR="${DIR}/../../examples/apps/colorapp"
COLOR_GATEWAY_IMAGE=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/gateway
COLOR_TELLER_IMAGE=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/colorteller
COLOR_TELLER_FRONTEND_IMAGE=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/gateway
COLOR_TELLER_BACKEND_IMAGE=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/colorteller

deploy_vpc() {
aws cloudformation deploy \
Expand All @@ -44,7 +44,7 @@ deploy_app() {
--stack-name "${RESOURCE_PREFIX}" \
--template-file "${DIR}/app.yaml" \
--capabilities CAPABILITY_IAM \
--parameter-overrides "EnvoyImage=${ENVOY_IMAGE}" "ColorTellerImage=${COLOR_TELLER_IMAGE}" "ColorGatewayImage=${COLOR_GATEWAY_IMAGE}"
--parameter-overrides "EnvoyImage=${ENVOY_IMAGE}" "ColorTellerBackendImage=${COLOR_TELLER_BACKEND_IMAGE}" "ColorTellerFrontendImage=${COLOR_TELLER_FRONTEND_IMAGE}"
}

confirm_service_linked_role() {
Expand All @@ -57,7 +57,7 @@ print_endpoint() {
echo "Public endpoint:"
prefix=$( aws cloudformation describe-stacks \
--stack-name="${RESOURCE_PREFIX}" \
--query="Stacks[0].Outputs[?OutputKey=='ColorGatewayEndpoint'].OutputValue" \
--query="Stacks[0].Outputs[?OutputKey=='ColorTellerFrontendEndpoint'].OutputValue" \
--output=text )
echo "${prefix}/color"
}
Expand Down
18 changes: 9 additions & 9 deletions walkthroughs/howto-servicediscovery-cloudmap/mesh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Resources:
Spec:
ServiceDiscovery:
AWSCloudMap:
ServiceName: "colorteller"
ServiceName: "colortellerbackend"
NamespaceName: !Sub "${AWS::StackName}.local"
Attributes:
- Key: "ECS_TASK_DEFINITION_FAMILY"
Expand All @@ -42,7 +42,7 @@ Resources:
Spec:
ServiceDiscovery:
AWSCloudMap:
ServiceName: "colorteller"
ServiceName: "colortellerbackend"
NamespaceName: !Sub "${AWS::StackName}.local"
Attributes:
- Key: "ECS_TASK_DEFINITION_FAMILY"
Expand All @@ -59,18 +59,18 @@ Resources:
TimeoutMillis: 2000
IntervalMillis: 5000

ColorGatewayNode:
ColorTellerFrontendNode:
Type: AWS::AppMesh::VirtualNode
DependsOn:
- ColorTellerService
- ColorTellerBackendService
Properties:
MeshName: !Ref AWS::StackName
VirtualNodeName: "colorgateway-node"
VirtualNodeName: "colortellerfrontend-node"
Spec:
ServiceDiscovery:
AWSCloudMap:
NamespaceName: !Sub "${AWS::StackName}.local"
ServiceName: "colorgateway"
ServiceName: "colortellerfrontend"
Listeners:
- PortMapping:
Port: 9080
Expand All @@ -84,15 +84,15 @@ Resources:
IntervalMillis: 5000
Backends:
- VirtualService:
VirtualServiceName: !Sub "colorteller.${AWS::StackName}.local"
VirtualServiceName: !Sub "colortellerbackend.${AWS::StackName}.local"

ColorTellerService:
ColorTellerBackendService:
Type: AWS::AppMesh::VirtualService
DependsOn:
- ColorTellerRouter
Properties:
MeshName: !Ref AWS::StackName
VirtualServiceName: !Sub "colorteller.${AWS::StackName}.local"
VirtualServiceName: !Sub "colortellerbackend.${AWS::StackName}.local"
Spec:
Provider:
VirtualRouter:
Expand Down