I have a DAG in Step Functions which is executed by an app within an ECS container. This DAG is scheduled to run every day. I'm seeing the following behavior:
Some random tasks fail with States. Timeout error (the timeout is set to 30 min)
I couldn't find the CloudWatch logs for these tasks that failed. This indicates that the tasks itself are never called.
Why this happens? Is there any setting I can use to prevent such behavior? Below follows the task code:
Input:
.
{
"version": "0",
"id": "ff4a2a37-7024-a213-70f0-11df9104484a",
"detail-type": "Scheduled Event",
"source": "aws.events",
"account": "",
"time": "2022-11-22T08:30:00Z",
"region": "us-east-1",
"resources": [
"arn:aws:events:rule/bi-datalake-hml"
],
"detail": {}
}
Output:
.
{
"Failures": [],
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-RequestId": [
"50737371-c24f-4901-98a5-bdef19278cf8"
],
"Content-Length": [
"2224"
],
"Date": [
"Tue, 22 Nov 2022 08:30:46 GMT"
],
"Content-Type": [
"application/x-amz-json-1.1"
]
},
"HttpHeaders": {
"Content-Length": "2224",
"Content-Type": "application/x-amz-json-1.1",
"Date": "Tue, 22 Nov 2022 08:30:46 GMT",
"x-amzn-RequestId": "50737371-c24f-4901-98a5-bdef19278cf8"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "50737371-c24f-4901-98a5-bdef19278cf8"
},
"Tasks": [
{
"Attachments": [
{
"Details": [
{
"Name": "subnetId",
"Value": "subnet-62d7664e"
}
],
"Id": "eacd4cdf-3ce8-4927-a869-52eb71f553b3",
"Status": "PRECREATED",
"Type": "ElasticNetworkInterface"
}
],
"Attributes": [
{
"Name": "ecs.cpu-architecture",
"Value": "x86_64"
}
],
"AvailabilityZone": "us-east-1c",
"ClusterArn": "arn:aws::cluster/bi-datalake-hml",
"Containers": [
{
"ContainerArn": "arn::container/bi-datalake-hml/ad12e4d9017443d889055024d1932ddf/eb1c44d5-01b8-4c52-8950-8676b6ecd949",
"Cpu": "0",
"GpuIds": [],
"Image": ".dkr.ecr.us-east-1.amazonaws.com/bi_dbtoncloud_hml:latest",
"LastStatus": "PENDING",
"ManagedAgents": [],
"Name": "bi_dbtoncloud_hml",
"NetworkBindings": [],
"NetworkInterfaces": [],
"TaskArn": "arn:aws:ecs:us-east-1::task/bi-datalake-hml/ad12e4d9017443d889055024d1932ddf"
}
],
"Cpu": "256",
"CreatedAt": 1669105846495,
"DesiredStatus": "RUNNING",
"EnableExecuteCommand": false,
"EphemeralStorage": {
"SizeInGiB": 20
},
"Group": "family:bi_dbtoncloud_hml",
"InferenceAccelerators": [],
"LastStatus": "PROVISIONING",
"LaunchType": "FARGATE",
"Memory": "1024",
"Overrides": {
"ContainerOverrides": [
{
"Command": [],
"Environment": [
{
"Name": "DBT_MODEL_TO_RUN",
"Value": "alpha_order_address_shipping"
},
{
"Name": "TASK_TOKEN",
"Value": "AQCIAAAAKgAAAAMAAAAAAAAAAaP+z4q5FgxDHKZhHvzNF0PDV8l/5AkxTlorAGbQfnjdDJE1P1NWf+Jj1OINDelJ0RLrsAtdwIDJcAFmehGFj9mGJ905+T9sdWmKbsSjHuR0fCksAw==vIiI8wfR+LDUo1zPl03VOvkCHUeD5mzrDBoyjVRpA7QuqJ8ocA5OmVSN6MEGg3eS24H/3m3/MZRbmRNydbvI5DIB9PDD5seYIJamDTlfqEtYESgxWBoPrlVmvuphEnw5orSIeh5sZpsKm3/AlzB4OsoZaJleWBd+1WQbWclKEpV9bG3aKCsJO5rYyVaI7Ik09lTrogpL0VeulC2q/rY4cXR/r3lPA9ZL9YalUXgqij2ZuZIRby63hEjzTcoIkieMQMRcRd7XmKb1p8LsE2nSfSRnRotn9JeKVn7/4UBmWx0iQUd/14Dw1TXUSDwUx0sAPN7dtv2RdnqdLfJI6LoJnuPagkySFTaPOsJ0jpgLi9cjsJMVlWboCXlH57fj0JNosDLisxYlf5R3lB4paspZ8DHfgfAW5Saywc/KCCby7wfyYvVKpXvsJFIoBdtXaXs9tlbyTmlg9Dy9Oaol33ZFhVrOuDTzgDf4x6Mguxz1cQEaze8Ui0G2NDCoNxPU+WffSkrsb0Pflf5LsPfHAuI2"
},
{
"Name": "DBT_ENV",
"Value": "hml"
}
],
"EnvironmentFiles": [],
"Name": "bi_dbtoncloud_hml",
"ResourceRequirements": []
}
],
"InferenceAcceleratorOverrides": []
},
"PlatformFamily": "Linux",
"PlatformVersion": "1.4.0",
"Tags": [],
"TaskArn": "arn:aws:ecs:us-east-1::task/bi-datalake-hml/ad12e4d9017443d889055024d1932ddf",
"TaskDefinitionArn": "arn:aws:ecs:us-east-1::task-definition/bi_dbtoncloud_hml:2",
"Version": 1
}
]
}
If you need more information, please let me know.
Related
I am running an AWS Batch array job with a few thousand children. When the parent job is complete, I'd like to trigger a lambda to do some cleanup on the output.
I can currently trigger an EventBridge rule when each child job finishes. How can we distinguish when the parent job completes?
EDIT: You can identify the parent job via
if ":" not in event["detail"]["jobId"]:
I'd also like to change the data included in the event signal, so I can tell my lambda what bucket the output went to, the name of the output file produced, etc. Can we customize the fields in an event created by Batch?
Currently, the events I'm getting look like this (account number removed):
{
"version": "0",
"id": "f6c74fc4-a943-9592-2be0-99df7b67f79f",
"detail-type": "Batch Job State Change",
"source": "aws.batch",
"account": "",
"time": "2022-12-07T22:51:38Z",
"region": "us-east-1",
"resources": [
"arn:aws:batch:us-east-1::job/138677dc-d684-4e39-b42f-6626515be7c7:2"
],
"detail": {
"jobArn": "arn:aws:batch:us-east-1::job/138677dc-d684-4e39-b42f-6626515be7c7:2",
"jobName": "event_test",
"jobId": "138677dc-d684-4e39-b42f-6626515be7c7:2",
"jobQueue": "arn:aws:batch:us-east-1::job-queue/HLM2",
"status": "SUCCEEDED",
"attempts": [
{
"container": {
"containerInstanceArn": "arn:aws:ecs:us-east-1::container-instance/AWSBatch-HLM2-c929f2e7-5cd9-3f96-8ad3-a2717fb4d2ec/6f1037214ed247aebe5ead4bf19e5929",
"taskArn": "arn:aws:ecs:us-east-1::task/AWSBatch-HLM2-c929f2e7-5cd9-3f96-8ad3-a2717fb4d2ec/5cb0c860da6a484ca6ba23a468a7f76c",
"exitCode": 0,
"logStreamName": "HLM2/default/5cb0c860da6a484ca6ba23a468a7f76c",
"networkInterfaces": []
},
"startedAt": 1670453438605,
"stoppedAt": 1670453497525,
"statusReason": "Essential container in task exited"
}
],
"statusReason": "Essential container in task exited",
"createdAt": 1670453294805,
"startedAt": 1670453438605,
"stoppedAt": 1670453497525,
"dependsOn": [],
"jobDefinition": "arn:aws:batch:us-east-1::job-definition/HLM2:8",
"parameters": {},
"container": {
"image": ".dkr.ecr.us-east-1.amazonaws.com/hlm:latest",
"command": [],
"jobRoleArn": "arn:aws:iam:::role/hlm-ec2-access-role",
"executionRoleArn": "arn:aws:iam:::role/hlm-ec2-access-role",
"volumes": [],
"environment": [],
"mountPoints": [],
"ulimits": [],
"exitCode": 0,
"containerInstanceArn": "arn:aws:ecs:us-east-1::container-instance/AWSBatch-HLM2-c929f2e7-5cd9-3f96-8ad3-a2717fb4d2ec/6f1037214ed247aebe5ead4bf19e5929",
"taskArn": "arn:aws:ecs:us-east-1::task/AWSBatch-HLM2-c929f2e7-5cd9-3f96-8ad3-a2717fb4d2ec/5cb0c860da6a484ca6ba23a468a7f76c",
"logStreamName": "HLM2/default/5cb0c860da6a484ca6ba23a468a7f76c",
"networkInterfaces": [],
"resourceRequirements": [
{
"value": "2",
"type": "VCPU"
},
{
"value": "8192",
"type": "MEMORY"
}
],
"secrets": []
},
"arrayProperties": {
"statusSummary": {},
"index": 2
},
"timeout": {
"attemptDurationSeconds": 1800
},
"tags": {
"resourceArn": "arn:aws:batch:us-east-1::job/138677dc-d684-4e39-b42f-6626515be7c7"
},
"platformCapabilities": [
"EC2"
],
"eksAttempts": []
}
}
I'm trying to set up a deployment pipeline using CodeCommit, ECR and ECS. My pipeline passes the source and builds the image right, except for deployment phase, where it fails:
The deployment failed because the AppSpec file that specifies the deployment configuration is missing or has an invalid configuration. The input AppSpec file is a not well-formed yaml. The template cannot be parsed.
appspec.yaml is in the output of my build phase (stored inside a zip file in S3)
The following is my code pipeline:
{
"pipeline": {
"name": "dashboardpipeline",
"roleArn": "arn:aws:iam::410208438878:role/service-role/AWSCodePipelineServiceRole-us-east-2-DashBoardPipeline",
"artifactStore": {
"type": "S3",
"location": "codepipeline-us-east-2-276644567431"
},
"stages": [
{
"name": "Source",
"actions": [
{
"name": "Source",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "CodeCommit",
"version": "1"
},
"runOrder": 2,
"configuration": {
"BranchName": "master",
"OutputArtifactFormat": "CODE_ZIP",
"PollForSourceChanges": "false",
"RepositoryName": "provisions_dashboard"
},
"outputArtifacts": [
{
"name": "SourceArtifact"
}
],
"inputArtifacts": [],
"region": "us-east-2",
"namespace": "SourceVariables"
},
{
"name": "Image",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "ECR",
"version": "1"
},
"runOrder": 2,
"configuration": {
"ImageTag": "latest",
"RepositoryName": "dashboard-web-app"
},
"outputArtifacts": [
{
"name": "MyImage"
}
],
"inputArtifacts": [],
"region": "us-east-2"
}
]
},
{
"name": "Build",
"actions": [
{
"name": "Build",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ProjectName": "DashboardApplicationBuild"
},
"outputArtifacts": [
{
"name": "BuildArtifact"
}
],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
],
"region": "us-east-2",
"namespace": "BuildVariables"
}
]
},
{
"name": "Deploy",
"actions": [
{
"name": "Deploy",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeployToECS",
"version": "1"
},
"runOrder": 1,
"configuration": {
"AppSpecTemplateArtifact": "BuildArtifact",
"AppSpecTemplatePath": "appspec.yaml",
"ApplicationName": "dashboarddeploymentapp",
"DeploymentGroupName": "dashboardappdeploygr",
"Image1ArtifactName": "MyImage",
"Image1ContainerName": "IMAGE_URI",
"TaskDefinitionTemplateArtifact": "BuildArtifact",
"TaskDefinitionTemplatePath": "taskdef.json"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "BuildArtifact"
},
{
"name": "MyImage"
}
],
"region": "us-east-2"
}
]
}
],
"version": 18
},
"metadata": {
"pipelineArn": "arn:aws:codepipeline:us-east-2:410208438878:dashboardpipeline",
"created": "2022-03-14T11:52:19.525000-03:00",
"updated": "2022-03-18T11:34:14.217000-03:00"
}
}
I have tried to bulk add a contact using API Try editor of Google https://developers.google.com/people/api/rest/v1/people/batchCreateContacts
{
"contacts": [
{
"contactPerson": {
"addresses": [
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
},
{
"formattedValue": "formattedValue",
"type": "type",
"poBox": "poBox",
"streetAddress": "streetAddress",
"extendedAddress": "extendedAddress",
"city": "city",
"region": "region",
"postalCode": "postalCode",
"country": "country",
"countryCode": "countryCode"
}
],
"biographies": [
{
"value": "biographies-value",
"contentType": "TEXT_PLAIN"
}
],
"birthdays": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"text": "22/09/1988"
}
],
"calendarUrls": [
{
"url": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "calendarUrls-type"
}
],
"clientData": [
{
"key": "clientData-key",
"value": "clientData-value"
}
],
"emailAddresses": [
{
"value": "emailAddresses-value",
"type": "emailAddresses-type",
"displayName": "emailAddresses-displayName"
}
],
"events": [
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 1988,
"month": 9,
"day": 22
},
"type": "events-type"
},
{
"date": {
"year": 2019,
"month": 12,
"day": 7
},
"type": "marriage"
}
],
"externalIds": [
{
"value": "externalIds-value",
"type": "externalIds-type"
}
],
"fileAses": [
{
"value": "fileAses-value"
}
],
"genders": [
{
"value": "male",
"addressMeAs": "her"
}
],
"imClients": [
{
"username": "imClients-username1",
"type": "imClients-typeA",
"protocol": "imClients-protocol1"
},
{
"username": "imClients-username2",
"type": "imClients-typeA",
"protocol": "imClients-protocol2"
},
{
"username": "imClients-username3",
"type": "imClients-typeB",
"protocol": "imClients-protocol3"
}
],
"interests": [
{
"value": "interests-value"
}
],
"locales": [
{
"value": "locales-value"
}
],
"locations": [
{
"value": "locations-value1",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
},
{
"value": "locations-value2",
"type": "desk",
"current": true,
"buildingId": "locations-buildingId",
"floor": "locations-floor",
"floorSection": "buildingId-floorSection",
"deskCode": "locations-deskCode"
}
],
"memberships": [
{
"contactGroupMembership": {
"contactGroupResourceName": "contactGroups/3616ed318c1125e3"
}
}
],
"miscKeywords": [
{
"value": "SENSITIVITY1",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "SENSITIVITY2",
"type": "OUTLOOK_SENSITIVITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_BILLING_INFORMATION",
"type": "OUTLOOK_BILLING_INFORMATION"
},
{
"value": "OUTLOOK_DIRECTORY_SERVER",
"type": "OUTLOOK_DIRECTORY_SERVER"
},
{
"value": "OUTLOOK_KEYWORD",
"type": "OUTLOOK_KEYWORD"
},
{
"value": "OUTLOOK_MILEAGE",
"type": "OUTLOOK_MILEAGE"
},
{
"value": "OUTLOOK_PRIORITY",
"type": "OUTLOOK_PRIORITY"
},
{
"value": "OUTLOOK_SUBJECT",
"type": "OUTLOOK_SUBJECT"
},
{
"value": "OUTLOOK_USER1-value",
"type": "OUTLOOK_USER"
},
{
"value": "OUTLOOK_USER2-value",
"type": "OUTLOOK_USER"
},
{
"value": "HOME",
"type": "HOME"
},
{
"value": "WORK",
"type": "WORK"
},
{
"value": "OTHER",
"type": "OTHER"
}
],
"names": [
{
"unstructuredName": "unstructuredName",
"familyName": "MrTest",
"givenName": "givenName",
"middleName": "middleName",
"honorificPrefix": "honorificPrefix",
"honorificSuffix": "honorificSuffix",
"phoneticFullName": "phoneticFullName",
"phoneticFamilyName": "phoneticFamilyName",
"phoneticGivenName": "phoneticGivenName",
"phoneticMiddleName": "phoneticMiddleName",
"phoneticHonorificPrefix": "phoneticHonorificPrefix",
"phoneticHonorificSuffix": "phoneticHonorificSuffix"
}
],
"nicknames": [
{
"value": "nicknames-value-alternate-name",
"type": "ALTERNATE_NAME"
},
{
"value": "nicknames-value-default",
"type": "DEFAULT"
}
],
"occupations": [
{
"value": "occupations-value"
}
],
"organizations": [
{
"type": "organizations-type",
"startDate": {
"year": 1988,
"month": 9,
"day": 22
},
"endDate": {
"year": 1988,
"month": 9,
"day": 22
},
"current": true,
"name": "organizations-name",
"phoneticName": "organizations-phoneticName",
"department": "organizations-department",
"title": "organizations-title",
"jobDescription": "organizations-jobDescription",
"symbol": "organizations-symbol",
"domain": "organizations-domain",
"location": "organizations-location"
}
],
"phoneNumbers": [
{
"value": "phoneNumbers-value",
"type": "phoneNumbers-type"
}
],
"relations": [
{
"person": "relations-person",
"type": "relations-type"
}
],
"sipAddresses": [
{
"value": "sipAddresses-value",
"type": "sipAddresses-type"
}
],
"urls": [
{
"value": "https://lh3.googleusercontent.com/ogw/ADea4I4kLm9hsAYNpD_7v-7wXki3joED-eg2ZHcGmp31",
"type": "urls-type"
}
],
"userDefined": [
{
"key": "userDefined-key",
"value": "userDefined-value"
}
]
}
}
],
"readMask": "emailAddresses,phoneNumbers,addresses,birthdays,biographies,calendarUrls,clientData,coverPhotos,events,externalIds,genders,imClients,interests,locales,locations,memberships,miscKeywords,names,nicknames,occupations,organizations,phoneNumbers,photos,relations,sipAddresses,skills,urls,userDefined"
}
I get the error as
{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
Am I missing something?
It looks like the 500 Internal Error message you are receiving is due to the fact that you are using the calendarUrls field in the request.
This might in fact be a bug so I have taken the opportunity to file a report on Google's Issue Tracker here.
I suggest you star the issue as all the updates will be posted there.
I have a problem with parsing output/transforming it from aws autoscaling describe-auto-scaling-groups
The output looks like this:
{
"AutoScalingGroups": [
{
"AutoScalingGroupName": "eks-nodegroup-AZ1",
"AutoScalingGroupARN": "arn:aws:autoscaling:eu-central-1::autoScalingGroup:854a8f05-cd3c-421d-abf3-0f3730d0b068:autoScalingGroupName/eks-nodegroup-AZ1",
"LaunchTemplate": {
"LaunchTemplateId": "lt-XXXXXXXXXXXXX",
"LaunchTemplateName": "eks-nodegroup-AZ1",
"Version": "$Latest"
},
"MinSize": 1,
"MaxSize": 6,
"DesiredCapacity": 1,
"DefaultCooldown": 300,
"AvailabilityZones": [
"eu-central-1a"
],
"LoadBalancerNames": [],
"TargetGroupARNs": [],
"HealthCheckType": "EC2",
"HealthCheckGracePeriod": 300,
"Instances": [
{
"InstanceId": "i-XXXXXXXXXXXXXXX",
"AvailabilityZone": "eu-central-1a",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
"LaunchTemplateId": "lt-XXXXXXXXXXXXX",
"LaunchTemplateName": "eks-nodegroup-AZ1",
"Version": "1"
},
"ProtectedFromScaleIn": false
}
],
"CreatedTime": "2019-09-24T17:24:57.805Z",
"SuspendedProcesses": [],
"VPCZoneIdentifier": "subnet-XXXXXXXXXXXX",
"EnabledMetrics": [],
"Tags": [
{
"ResourceId": "eks-nodegroup-AZ1",
"ResourceType": "auto-scaling-group",
"Key": "Name",
"Value": "eks-nodegroup-AZ1",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ1",
"ResourceType": "auto-scaling-group",
"Key": "k8s.io/cluster-autoscaler/enabled",
"Value": "true",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ1",
"ResourceType": "auto-scaling-group",
"Key": "k8s.io/cluster-autoscaler/k8s-team-sandbox",
"Value": "true",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ1",
"ResourceType": "auto-scaling-group",
"Key": "kubernetes.io/cluster/k8s-team-sandbox",
"Value": "owned",
"PropagateAtLaunch": true
}
],
"TerminationPolicies": [
"Default"
],
"NewInstancesProtectedFromScaleIn": false,
"ServiceLinkedRoleARN": "arn:aws:iam::XXXXXXXXXXXXXXX:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
},
{
"AutoScalingGroupName": "eks-k8s-team-sandbox-AZ2",
"AutoScalingGroupARN": "arn:aws:autoscaling:eu-central-1::autoScalingGroup:25324f3a-b911-453c-b316-46657e850b19:autoScalingGroupName/eks-nodegroup-AZ2",
"LaunchTemplate": {
"LaunchTemplateId": "lt-XXXXXXXXXXXX",
"LaunchTemplateName": "eks-nodegroup-AZ2",
"Version": "$Latest"
},
"MinSize": 1,
"MaxSize": 6,
"DesiredCapacity": 1,
"DefaultCooldown": 300,
"AvailabilityZones": [
"eu-central-1b"
],
"LoadBalancerNames": [],
"TargetGroupARNs": [],
"HealthCheckType": "EC2",
"HealthCheckGracePeriod": 300,
"Instances": [
{
"InstanceId": "i-XXXXXXXXXXXX",
"AvailabilityZone": "eu-central-1b",
"LifecycleState": "InService",
"HealthStatus": "Healthy",
"LaunchTemplate": {
"LaunchTemplateId": "lt-XXXXXXXXXX",
"LaunchTemplateName": "eks-nodegroup-AZ2",
"Version": "1"
},
"ProtectedFromScaleIn": false
}
],
"CreatedTime": "2019-09-24T17:24:57.982Z",
"SuspendedProcesses": [],
"VPCZoneIdentifier": "subnet-XXXXXXXX",
"EnabledMetrics": [],
"Tags": [
{
"ResourceId": "eks-nodegroup-AZ2",
"ResourceType": "auto-scaling-group",
"Key": "Name",
"Value": "eks-nodegroup-AZ2",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ2",
"ResourceType": "auto-scaling-group",
"Key": "k8s.io/cluster-autoscaler/enabled",
"Value": "true",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ2",
"ResourceType": "auto-scaling-group",
"Key": "k8s.io/cluster-autoscaler/k8s-team-sandbox",
"Value": "true",
"PropagateAtLaunch": true
},
{
"ResourceId": "eks-nodegroup-AZ2",
"ResourceType": "auto-scaling-group",
"Key": "kubernetes.io/cluster/k8s-team-sandbox",
"Value": "owned",
"PropagateAtLaunch": true
}
],
"TerminationPolicies": [
"Default"
],
"NewInstancesProtectedFromScaleIn": false,
"ServiceLinkedRoleARN": "arn:aws:iam::ARN:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling"
}
]
}
I need to parse it to get :
{
"eks-nodegroup-AZ1" : "$DesiredCapacityForEks-nodegroup-AZ1",
"eks-nodegroup-AZ2" : "$DesiredCapacityForEks-nodegroup-AZ2",
"eks-nodegroup-AZ3" : "$DesiredCapacityForEks-nodegroup-AZ3",
"eks-nodegroup-AZX" : "$DesiredCapacityForEks-nodegroup-AZX",
}
The following expected output will be used for external data resource for terraform to be able to automate DesiredCapacity value during the ASG rolling-updates.
Thanks,
Dominik
Try with your response,
response | jq '.AutoScalingGroups[] | {(.AutoScalingGroupName): .DesiredCapacity}' | jq -s add
I have the need to find the hostname of my ECS task via the CLI, which according to the Amazon documentation should be available via the CLI:
https://docs.aws.amazon.com/cli/latest/reference/ecs/describe-task-definition.html
However, when I run the describe-task-definition it is not returning the information:
> aws ecs describe-task-definition --task-definition my-test-task:1
{
"taskDefinition": {
"status": "ACTIVE",
"networkMode": "bridge",
"family": "my-test-task",
"placementConstraints": [],
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
}
],
"volumes": [
{
"host": {
"sourcePath": "/opt/cf/rails-app/public/"
},
"name": "ruby-on-rails-public-volume"
}
],
"taskDefinitionArn": "arn:aws:ecs:us-east-1:accountId:task-definition/my-test-task:1",
"containerDefinitions": [
{
"memoryReservation": 1024,
"environment": [
{
"name": "DATABASE_HOSTNAME",
"value": "hostname"
},
{
"name": "PUMA_WORKERS",
"value": "2"
},
{
"name": "RAILS_ENV",
"value": "staging"
},
{
"name": "DATABASE_NAME",
"value": "ruby-on-rails"
},
{
"name": "DEBIAN_FRONTEND",
"value": "noninteractive"
},
{
"name": "PORT",
"value": "8080"
},
{
"name": "LANG",
"value": "en_US.UTF-8"
},
{
"name": "DATABASE_PASSWORD",
"value": "cf"
},
{
"name": "DATABASE_USER",
"value": "cf"
},
{
"name": "PUMA_MAX_THREADS",
"value": "6"
}
],
"name": "my-test-task",
"mountPoints": [
{
"sourceVolume": "ruby-on-rails-public-volume",
"containerPath": "/opt/cf/rails-app/public/"
}
],
"image": "accountId.dkr.ecr.us-east-1.amazonaws.com/cf/rails:latest",
"cpu": 1024,
"portMappings": [
{
"protocol": "tcp",
"containerPort": 8080,
"hostPort": 8080
}
],
"command": [
"puma",
"-C",
"config/puma.rb"
],
"essential": true,
"volumesFrom": []
}
],
"revision": 1
}
}
I am not sure what I need to do to get that value included. I confirmed I am running the latest CLI.
Thanks!
First of all the hoostname is not defined to task definition. Its defined to container definition inside task definition. Secondly, There is no default hostname, You have to explicitly define the hostname in the container definition while creating task definition revision. By default, it uses container id as the hostname.