I'm using .NET Core WEBAPI and below Dockerfile
FROM microsoft/dotnet:sdk AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
# Build runtime image
FROM microsoft/dotnet:aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "DummyService.dll"]
In my cloudformation template, the ECS part looks like this
dummyWebApiEcsTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref AWS::StackName
TaskRoleArn: !GetAtt dummyWebApiIamRole.Arn
ContainerDefinitions:
- Name: !Ref AWS::StackName
Image: MY IMAGE URL
DnsSearchDomains:
- !Join [".", [{"Fn::ImportValue": !Sub "${accountStackName}-${AWS::Region}-envName"}, "connected", !If [chinaPartition, "TEST", "CORP"], "cloud"]]
LogConfiguration:
LogDriver: splunk
Options:
splunk-token: {"Fn::ImportValue": !Sub "${splunkHECStackName}-${AWS::Region}-SplunkHECToken"}
splunk-url: "http://splunk-forwarder:8088"
splunk-insecureskipverify: True
tag: !Ref AWS::StackName
splunk-format: json
splunk-source: !Ref AWS::StackName
splunk-sourcetype: AWS:ECS
EntryPoint: []
PortMappings:
- ContainerPort: 5000
Command: []
Cpu: 0
Environment:
- Name: BindAddress
Value: http://0.0.0.0:5000
- Name: MinLogLevel
Value: !If [isProduction, "Information", "Debug"]
Ulimits: []
DnsServers: []
MountPoints: []
DockerSecurityOptions: []
Memory: 512
VolumesFrom: []
Essential: true
ExtraHosts: []
ReadonlyRootFilesystem: false
DockerLabels: {}
Privileged: false
dummyEcsService:
Type: AWS::ECS::Service
DependsOn:
- dummyWebApiIamRole
- dummyInternalAlb
- dummyAlbTargetGroup
Properties:
Cluster:
Fn::ImportValue: !Sub "cld-core-ecs-${AWS::Region}-ECSCluster"
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 50
DesiredCount: 2
LoadBalancers:
- ContainerName: !Ref AWS::StackName
ContainerPort: 5000
TargetGroupArn: !Ref dummyAlbTargetGroup
PlacementStrategies:
- Type: spread
Field: attribute:ecs.availability-zone
TaskDefinition: !Ref dummyWebApiEcsTaskDefinition
ServiceName: !Ref AWS::StackName
Role: !Sub "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS"
The deployment couldn't finish and I can see this error in the ECS Service Events tab
service cld-dummy-test was unable to place a task because no container instance met all of its requirements. Reason: No Container Instances were found in your cluster.