Container is connecting default cluster when trying to setup new ECS Cluster - docker

I am using following cloud formation script to create a new ECS cluster
*{
"AWSTemplateFormatVersion":"2010-09-09",
"Parameters":{
"KeyName":{
"Type":"AWS::EC2::KeyPair::KeyName",
"Description":"Name of an existing EC2 KeyPair to enable SSH access to the ECS instances."
},
"VpcId":{
"Type":"AWS::EC2::VPC::Id",
"Description":"Select a VPC that allows instances to access the Internet."
},
"SubnetId":{
"Type":"List<AWS::EC2::Subnet::Id>",
"Description":"Select at two subnets in your selected VPC."
},
"DesiredCapacity":{
"Type":"Number",
"Default":"1",
"Description":"Number of instances to launch in your ECS cluster."
},
"MaxSize":{
"Type":"Number",
"Default":"1",
"Description":"Maximum number of instances that can be launched in your ECS cluster."
},
"InstanceType":{
"Description":"EC2 instance type",
"Type":"String",
"Default":"t2.micro",
"AllowedValues":[
"t2.micro",
"t2.small",
"t2.medium",
"t2.large",
"m3.medium",
"m3.large",
"m3.xlarge",
"m3.2xlarge",
"m4.large",
"m4.xlarge",
"m4.2xlarge",
"m4.4xlarge",
"m4.10xlarge",
"c4.large",
"c4.xlarge",
"c4.2xlarge",
"c4.4xlarge",
"c4.8xlarge",
"c3.large",
"c3.xlarge",
"c3.2xlarge",
"c3.4xlarge",
"c3.8xlarge",
"r3.large",
"r3.xlarge",
"r3.2xlarge",
"r3.4xlarge",
"r3.8xlarge",
"i2.xlarge",
"i2.2xlarge",
"i2.4xlarge",
"i2.8xlarge"
],
"ConstraintDescription":"Please choose a valid instance type."
}
},
"Mappings":{
"AWSRegionToAMI":{
"us-east-1":{
"AMIID":"ami-0c65e6401a50512c5"
}
}
},
"Resources":{
"ECSCluster":{
"Type":"AWS::ECS::Cluster"
},
"EcsSecurityGroup":{
"Type":"AWS::EC2::SecurityGroup",
"Properties":{
"GroupDescription":"ECS Security Group",
"VpcId":{
"Ref":"VpcId"
}
}
},
"EcsSecurityGroupHTTPinbound":{
"Type":"AWS::EC2::SecurityGroupIngress",
"Properties":{
"GroupId":{
"Ref":"EcsSecurityGroup"
},
"IpProtocol":"tcp",
"FromPort":"80",
"ToPort":"80",
"CidrIp":"0.0.0.0/0"
}
},
"EcsSecurityGroupSSHinbound":{
"Type":"AWS::EC2::SecurityGroupIngress",
"Properties":{
"GroupId":{
"Ref":"EcsSecurityGroup"
},
"IpProtocol":"tcp",
"FromPort":"22",
"ToPort":"22",
"CidrIp":"0.0.0.0/0"
}
},
"EcsSecurityGroupALBports":{
"Type":"AWS::EC2::SecurityGroupIngress",
"Properties":{
"GroupId":{
"Ref":"EcsSecurityGroup"
},
"IpProtocol":"tcp",
"FromPort":"31000",
"ToPort":"61000",
"SourceSecurityGroupId":{
"Ref":"EcsSecurityGroup"
}
}
},
"CloudwatchLogsGroup":{
"Type":"AWS::Logs::LogGroup",
"Properties":{
"LogGroupName":{
"Fn::Join":[
"-",
[
"ECSLogGroup",
{
"Ref":"AWS::StackName"
}
]
]
},
"RetentionInDays":14
}
},
"taskdefinition":{
"Type":"AWS::ECS::TaskDefinition",
"Properties":{
"Family":{
"Fn::Join":[
"",
[
{
"Ref":"AWS::StackName"
},
"-ecs-demo-app"
]
]
},
"ContainerDefinitions":[
{
"Name":"simple-app",
"Cpu":"10",
"Essential":"true",
"Image":"httpd:2.4",
"Memory":"300",
"LogConfiguration":{
"LogDriver":"awslogs",
"Options":{
"awslogs-group":{
"Ref":"CloudwatchLogsGroup"
},
"awslogs-region":{
"Ref":"AWS::Region"
},
"awslogs-stream-prefix":"ecs-demo-app"
}
},
"MountPoints":[
{
"ContainerPath":"/usr/local/apache2/htdocs",
"SourceVolume":"my-vol"
}
],
"PortMappings":[
{
"ContainerPort":80
}
]
},
{
"Name":"busybox",
"Cpu":10,
"Command":[
"/bin/sh -c \"while true; do echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p>' > top; /bin/date > date ; echo '</div></body></html>' > bottom; cat top date bottom > /usr/local/apache2/htdocs/index.html ; sleep 1; done\""
],
"EntryPoint":[
"sh",
"-c"
],
"Essential":false,
"Image":"busybox",
"Memory":200,
"LogConfiguration":{
"LogDriver":"awslogs",
"Options":{
"awslogs-group":{
"Ref":"CloudwatchLogsGroup"
},
"awslogs-region":{
"Ref":"AWS::Region"
},
"awslogs-stream-prefix":"ecs-demo-app"
}
},
"VolumesFrom":[
{
"SourceContainer":"simple-app"
}
]
}
],
"Volumes":[
{
"Name":"my-vol"
}
]
}
},
"ECSALB":{
"Type":"AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties":{
"Name":"ECSALB",
"Scheme":"internet-facing",
"LoadBalancerAttributes":[
{
"Key":"idle_timeout.timeout_seconds",
"Value":"30"
}
],
"Subnets":{
"Ref":"SubnetId"
},
"SecurityGroups":[
{
"Ref":"EcsSecurityGroup"
}
]
}
},
"ALBListener":{
"Type":"AWS::ElasticLoadBalancingV2::Listener",
"DependsOn":"ECSServiceRole",
"Properties":{
"DefaultActions":[
{
"Type":"forward",
"TargetGroupArn":{
"Ref":"ECSTG"
}
}
],
"LoadBalancerArn":{
"Ref":"ECSALB"
},
"Port":"80",
"Protocol":"HTTP"
}
},
"ECSALBListenerRule":{
"Type":"AWS::ElasticLoadBalancingV2::ListenerRule",
"DependsOn":"ALBListener",
"Properties":{
"Actions":[
{
"Type":"forward",
"TargetGroupArn":{
"Ref":"ECSTG"
}
}
],
"Conditions":[
{
"Field":"path-pattern",
"Values":[
"/"
]
}
],
"ListenerArn":{
"Ref":"ALBListener"
},
"Priority":1
}
},
"ECSTG":{
"Type":"AWS::ElasticLoadBalancingV2::TargetGroup",
"DependsOn":"ECSALB",
"Properties":{
"HealthCheckIntervalSeconds":10,
"HealthCheckPath":"/",
"HealthCheckProtocol":"HTTP",
"HealthCheckTimeoutSeconds":5,
"HealthyThresholdCount":2,
"Name":"ECSTG",
"Port":80,
"Protocol":"HTTP",
"UnhealthyThresholdCount":2,
"VpcId":{
"Ref":"VpcId"
}
}
},
"ECSAutoScalingGroup":{
"Type":"AWS::AutoScaling::AutoScalingGroup",
"Properties":{
"VPCZoneIdentifier":{
"Ref":"SubnetId"
},
"LaunchConfigurationName":{
"Ref":"ContainerInstances"
},
"MinSize":"1",
"MaxSize":{
"Ref":"MaxSize"
},
"DesiredCapacity":{
"Ref":"DesiredCapacity"
}
},
"CreationPolicy":{
"ResourceSignal":{
"Timeout":"PT300M"
}
},
"UpdatePolicy":{
"AutoScalingReplacingUpdate":{
"WillReplace":"true"
}
}
},
"ContainerInstances":{
"Type":"AWS::AutoScaling::LaunchConfiguration",
"Properties":{
"ImageId":{
"Fn::FindInMap":[
"AWSRegionToAMI",
{
"Ref":"AWS::Region"
},
"AMIID"
]
},
"SecurityGroups":[
{
"Ref":"EcsSecurityGroup"
}
],
"InstanceType":{
"Ref":"InstanceType"
},
"IamInstanceProfile":{
"Ref":"EC2InstanceProfile"
},
"KeyName":{
"Ref":"KeyName"
},
"UserData":{
"Fn::Base64": {
"Fn::Join": [
"",
[
"#!/bin/bash\n",
"# Install the files and packages from the metadata\n",
"sudo /opt/aws/bin/cfn-init -v ",
" --stack ",
{
"Ref": "AWS::StackName"
},
" --resource ContainerInstances ",
" --region ",
{
"Ref": "AWS::Region"
},
"\n",
"sudo yum -y update \n",
"# Signal the status from cfn-init\n",
"sudo /opt/aws/bin/cfn-signal -e $? ",
" --stack ",
{
"Ref": "AWS::StackName"
},
" --resource ECSAutoScalingGroup ",
" --region ",
{
"Ref": "AWS::Region"
},
"\n"
]
]
}
}
}
},
"service":{
"Type":"AWS::ECS::Service",
"DependsOn":"ALBListener",
"Properties":{
"Cluster":{
"Ref":"ECSCluster"
},
"DesiredCount":"1",
"LoadBalancers":[
{
"ContainerName":"simple-app",
"ContainerPort":"80",
"TargetGroupArn":{
"Ref":"ECSTG"
}
}
],
"Role":{
"Ref":"ECSServiceRole"
},
"TaskDefinition":{
"Ref":"taskdefinition"
}
}
},
"ECSServiceRole":{
"Type":"AWS::IAM::Role",
"Properties":{
"AssumeRolePolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":[
"ecs.amazonaws.com"
]
},
"Action":[
"sts:AssumeRole"
]
}
]
},
"Path":"/",
"Policies":[
{
"PolicyName":"ecs-service",
"PolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Action":[
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
"elasticloadbalancing:DeregisterTargets",
"elasticloadbalancing:Describe*",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"elasticloadbalancing:RegisterTargets",
"ec2:Describe*",
"ec2:AuthorizeSecurityGroupIngress"
],
"Resource":"*"
}
]
}
}
]
}
},
"ServiceScalingTarget":{
"Type":"AWS::ApplicationAutoScaling::ScalableTarget",
"DependsOn":"service",
"Properties":{
"MaxCapacity":2,
"MinCapacity":1,
"ResourceId":{
"Fn::Join":[
"",
[
"service/",
{
"Ref":"ECSCluster"
},
"/",
{
"Fn::GetAtt":[
"service",
"Name"
]
}
]
]
},
"RoleARN":{
"Fn::GetAtt":[
"AutoscalingRole",
"Arn"
]
},
"ScalableDimension":"ecs:service:DesiredCount",
"ServiceNamespace":"ecs"
}
},
"ServiceScalingPolicy":{
"Type":"AWS::ApplicationAutoScaling::ScalingPolicy",
"Properties":{
"PolicyName":"AStepPolicy",
"PolicyType":"StepScaling",
"ScalingTargetId":{
"Ref":"ServiceScalingTarget"
},
"StepScalingPolicyConfiguration":{
"AdjustmentType":"PercentChangeInCapacity",
"Cooldown":60,
"MetricAggregationType":"Average",
"StepAdjustments":[
{
"MetricIntervalLowerBound":0,
"ScalingAdjustment":200
}
]
}
}
},
"ALB500sAlarmScaleUp":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"EvaluationPeriods":"1",
"Statistic":"Average",
"Threshold":"10",
"AlarmDescription":"Alarm if our ALB generates too many HTTP 500s.",
"Period":"60",
"AlarmActions":[
{
"Ref":"ServiceScalingPolicy"
}
],
"Namespace":"AWS/ApplicationELB",
"Dimensions":[
{
"Name":"LoadBalancer",
"Value":{
"Fn::GetAtt" : [
"ECSALB",
"LoadBalancerFullName"
]
}
}
],
"ComparisonOperator":"GreaterThanThreshold",
"MetricName":"HTTPCode_ELB_5XX_Count"
}
},
"EC2Role":{
"Type":"AWS::IAM::Role",
"Properties":{
"AssumeRolePolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":[
"ec2.amazonaws.com"
]
},
"Action":[
"sts:AssumeRole"
]
}
]
},
"Path":"/",
"Policies":[
{
"PolicyName":"ecs-service",
"PolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Action":[
"ec2:DescribeTags",
"ecs:CreateCluster",
"ecs:DeregisterContainerInstance",
"ecs:DiscoverPollEndpoint",
"ecs:Poll",
"ecs:RegisterContainerInstance",
"ecs:StartTelemetrySession",
"ecs:UpdateContainerInstancesState",
"ecs:Submit*",
"ecr:GetAuthorizationToken",
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource":"*"
}
]
}
}
]
}
},
"AutoscalingRole":{
"Type":"AWS::IAM::Role",
"Properties":{
"AssumeRolePolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Principal":{
"Service":[
"application-autoscaling.amazonaws.com"
]
},
"Action":[
"sts:AssumeRole"
]
}
]
},
"Path":"/",
"Policies":[
{
"PolicyName":"service-autoscaling",
"PolicyDocument":{
"Statement":[
{
"Effect":"Allow",
"Action":[
"application-autoscaling:*",
"cloudwatch:DescribeAlarms",
"cloudwatch:PutMetricAlarm",
"ecs:DescribeServices",
"ecs:UpdateService"
],
"Resource":"*"
}
]
}
}
]
}
},
"EC2InstanceProfile":{
"Type":"AWS::IAM::InstanceProfile",
"Properties":{
"Path":"/",
"Roles":[
{
"Ref":"EC2Role"
}
]
}
}
},
"Outputs":{
"ecsservice":{
"Value":{
"Ref":"service"
}
},
"ecscluster":{
"Value":{
"Ref":"ECSCluster"
}
},
"ECSALB":{
"Description":"Your ALB DNS URL",
"Value":{
"Fn::Join":[
"",
[
{
"Fn::GetAtt":[
"ECSALB",
"DNSName"
]
}
]
]
}
},
"taskdef":{
"Value":{
"Ref":"taskdefinition"
}
}
}
}*
It got stuck in creating the service resource.
When I try to debug this, I found in the log on EC2 instance for ecs-agent docker:
Registration completed successfully. I am running as 'arn:aws:ecs:us-east-1:504254995642:container-instance/22a5c138-61b0-454f-b64e-f49a76fc6cbe' in cluster 'default'
Please can you suggest how can I configure it to 'my-cluster'

You'll need to add ECS_CLUSTER=my_cluster to /etc/ecs/ecs.config in userData script. That way you're telling ecs-agent to register itself to the correct ECS cluster.
From here.
Here is an example of doing this.
Hope it helps.

Related

Spell corrections not working when refining queries with aggregations

I'm searching for list items using the /search/query endpoint of MS Graph. I want to use aggregations and spell checking. This is my request
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"aggregations": [
{
"field": "fileType",
"size": 20,
"bucketDefinition": {
"sortBy": "count",
"isDescending": "true",
"minimumCount": 0
}
}
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
It returns no results, since the search term was not spell checked and modified:
{
"value": [
{
"searchTerms": [
"inspring"
],
"hitsContainers": [
{
"total": 0,
"moreResultsAvailable": false
}
]
}
],
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.searchResponse)"
}
However, when I remove the aggregations and use the following request, it works:
{
"requests": [
{
"entityTypes": [
"listItem"
],
"query": {
"queryString": "inspring"
},
"fields": [
"title"
],
"queryAlterationOptions": {
"enableModification": true
}
}
]
}
Response:
{
{
"value": [
{
"searchTerms": [
"inspiring"
],
"hitsContainers": [
{
"hits": [...],
"total": 64,
"moreResultsAvailable": true
}
],
"queryAlterationResponse": {
"originalQueryString": "inspring",
"queryAlteration": {
"alteredQueryString": "inspiring",
"alteredHighlightedQueryString": "inspiring",
"alteredQueryTokens": [
{
"offset": 0,
"length": 8,
"suggestion": "inspiring"
}
]
},
"queryAlterationType": "modification"
}
}
],
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)"
}
How do I have to change my request to make query alterations work with aggregations?

Cloudformation stacks, then how can I find the reason or log

When deploying from template,
This service is stack as CREATE_IN_PROGRESS
ServiceD69D759B arn:aws:ecs:ap-northeast-1:6781002281XX:service/AdminCluster/CdkFargateStack-ServiceD69D759B-sm274jjTfbP7 AWS::ECS::Service CREATE_IN_PROGRESS Resource creation Initiated -
However I have no idea where to start.
This docker image receive the access from 8011, so in local
it works in local like this
docker run -p 8011:8011 -it st_admin_site:latest
I check CloudWatch but can't find the log.
This is my cdk command
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const cluster = new ecs.Cluster(this, "SampleCluster", {
clusterName: "AdminCluster"
});
const adminImage = ecs.ContainerImage.fromRegistry('st_admin_site:latest');
const taskDefinition = new ecs.FargateTaskDefinition(this, "TaskDef");
const container = taskDefinition.addContainer("DefaultContainer", {
image: adminImage,
memoryLimitMiB: 512,
cpu: 256
});
container.addPortMappings({
containerPort: 8011
});
const ecsService = new ecs.FargateService(this, "Service", {
cluster,
taskDefinition,
desiredCount: 2
});
const lb = new elb.ApplicationLoadBalancer(this, "LB", {
vpc: cluster.vpc,
internetFacing: true
});
const listener = lb.addListener("Listener", { port: 80 });
const targetGroup = listener.addTargets("ECS", {
protocol: elb.ApplicationProtocol.HTTP,
port: 8011,
targets: [ecsService]
});
And it makes the template.
{
"Resources": {
"SampleClusterB4B72990": {
"Type": "AWS::ECS::Cluster",
"Properties": {
"ClusterName": "AdminCluster"
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Resource"
}
},
"SampleClusterVpcD1C6ABD9": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": "10.0.0.0/16",
"EnableDnsHostnames": true,
"EnableDnsSupport": true,
"InstanceTenancy": "default",
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/Resource"
}
},
"SampleClusterVpcPublicSubnet1SubnetE377A512": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.0.0/18",
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"AvailabilityZone": {
"Fn::Select": [
0,
{
"Fn::GetAZs": ""
}
]
},
"MapPublicIpOnLaunch": true,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "Public"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Public"
},
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/Subnet"
}
},
"SampleClusterVpcPublicSubnet1RouteTable7114D244": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/RouteTable"
}
},
"SampleClusterVpcPublicSubnet1RouteTableAssociation0B5402E3": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPublicSubnet1RouteTable7114D244"
},
"SubnetId": {
"Ref": "SampleClusterVpcPublicSubnet1SubnetE377A512"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/RouteTableAssociation"
}
},
"SampleClusterVpcPublicSubnet1DefaultRoute28A82BC4": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPublicSubnet1RouteTable7114D244"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "SampleClusterVpcIGW21649D5C"
}
},
"DependsOn": [
"SampleClusterVpcVPCGW39AFB859"
],
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/DefaultRoute"
}
},
"SampleClusterVpcPublicSubnet1EIPD2C3FC83": {
"Type": "AWS::EC2::EIP",
"Properties": {
"Domain": "vpc",
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/EIP"
}
},
"SampleClusterVpcPublicSubnet1NATGateway715FE613": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"SubnetId": {
"Ref": "SampleClusterVpcPublicSubnet1SubnetE377A512"
},
"AllocationId": {
"Fn::GetAtt": [
"SampleClusterVpcPublicSubnet1EIPD2C3FC83",
"AllocationId"
]
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet1/NATGateway"
}
},
"SampleClusterVpcPublicSubnet2SubnetB88D2B08": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.64.0/18",
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"AvailabilityZone": {
"Fn::Select": [
1,
{
"Fn::GetAZs": ""
}
]
},
"MapPublicIpOnLaunch": true,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "Public"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Public"
},
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/Subnet"
}
},
"SampleClusterVpcPublicSubnet2RouteTable8A11EEAD": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/RouteTable"
}
},
"SampleClusterVpcPublicSubnet2RouteTableAssociation857BF408": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPublicSubnet2RouteTable8A11EEAD"
},
"SubnetId": {
"Ref": "SampleClusterVpcPublicSubnet2SubnetB88D2B08"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/RouteTableAssociation"
}
},
"SampleClusterVpcPublicSubnet2DefaultRouteFD4087CF": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPublicSubnet2RouteTable8A11EEAD"
},
"DestinationCidrBlock": "0.0.0.0/0",
"GatewayId": {
"Ref": "SampleClusterVpcIGW21649D5C"
}
},
"DependsOn": [
"SampleClusterVpcVPCGW39AFB859"
],
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/DefaultRoute"
}
},
"SampleClusterVpcPublicSubnet2EIPCB2281EA": {
"Type": "AWS::EC2::EIP",
"Properties": {
"Domain": "vpc",
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/EIP"
}
},
"SampleClusterVpcPublicSubnet2NATGatewayB385D543": {
"Type": "AWS::EC2::NatGateway",
"Properties": {
"SubnetId": {
"Ref": "SampleClusterVpcPublicSubnet2SubnetB88D2B08"
},
"AllocationId": {
"Fn::GetAtt": [
"SampleClusterVpcPublicSubnet2EIPCB2281EA",
"AllocationId"
]
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PublicSubnet2/NATGateway"
}
},
"SampleClusterVpcPrivateSubnet1Subnet24256A44": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.128.0/18",
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"AvailabilityZone": {
"Fn::Select": [
0,
{
"Fn::GetAZs": ""
}
]
},
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "Private"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Private"
},
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1/Subnet"
}
},
"SampleClusterVpcPrivateSubnet1RouteTable55080EB4": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1/RouteTable"
}
},
"SampleClusterVpcPrivateSubnet1RouteTableAssociationBC171CD8": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPrivateSubnet1RouteTable55080EB4"
},
"SubnetId": {
"Ref": "SampleClusterVpcPrivateSubnet1Subnet24256A44"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1/RouteTableAssociation"
}
},
"SampleClusterVpcPrivateSubnet1DefaultRouteB1C5B147": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPrivateSubnet1RouteTable55080EB4"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "SampleClusterVpcPublicSubnet1NATGateway715FE613"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet1/DefaultRoute"
}
},
"SampleClusterVpcPrivateSubnet2Subnet25DCB36D": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"CidrBlock": "10.0.192.0/18",
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"AvailabilityZone": {
"Fn::Select": [
1,
{
"Fn::GetAZs": ""
}
]
},
"MapPublicIpOnLaunch": false,
"Tags": [
{
"Key": "aws-cdk:subnet-name",
"Value": "Private"
},
{
"Key": "aws-cdk:subnet-type",
"Value": "Private"
},
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2/Subnet"
}
},
"SampleClusterVpcPrivateSubnet2RouteTable35B9289E": {
"Type": "AWS::EC2::RouteTable",
"Properties": {
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2/RouteTable"
}
},
"SampleClusterVpcPrivateSubnet2RouteTableAssociationC174EB56": {
"Type": "AWS::EC2::SubnetRouteTableAssociation",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPrivateSubnet2RouteTable35B9289E"
},
"SubnetId": {
"Ref": "SampleClusterVpcPrivateSubnet2Subnet25DCB36D"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2/RouteTableAssociation"
}
},
"SampleClusterVpcPrivateSubnet2DefaultRoute74AE4D72": {
"Type": "AWS::EC2::Route",
"Properties": {
"RouteTableId": {
"Ref": "SampleClusterVpcPrivateSubnet2RouteTable35B9289E"
},
"DestinationCidrBlock": "0.0.0.0/0",
"NatGatewayId": {
"Ref": "SampleClusterVpcPublicSubnet2NATGatewayB385D543"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/PrivateSubnet2/DefaultRoute"
}
},
"SampleClusterVpcIGW21649D5C": {
"Type": "AWS::EC2::InternetGateway",
"Properties": {
"Tags": [
{
"Key": "Name",
"Value": "CdkFargateStack/SampleCluster/Vpc"
}
]
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/IGW"
}
},
"SampleClusterVpcVPCGW39AFB859": {
"Type": "AWS::EC2::VPCGatewayAttachment",
"Properties": {
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
},
"InternetGatewayId": {
"Ref": "SampleClusterVpcIGW21649D5C"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/SampleCluster/Vpc/VPCGW"
}
},
"TaskDefTaskRole1EDB4A67": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "ecs-tasks.amazonaws.com"
}
}
],
"Version": "2012-10-17"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/TaskDef/TaskRole/Resource"
}
},
"TaskDef54694570": {
"Type": "AWS::ECS::TaskDefinition",
"Properties": {
"ContainerDefinitions": [
{
"Cpu": 256,
"Essential": true,
"Image": "st_admin_site:latest",
"Memory": 512,
"Name": "DefaultContainer",
"PortMappings": [
{
"ContainerPort": 8011,
"Protocol": "tcp"
}
]
}
],
"Cpu": "256",
"Family": "CdkFargateStackTaskDef424235B4",
"Memory": "512",
"NetworkMode": "awsvpc",
"RequiresCompatibilities": [
"FARGATE"
],
"TaskRoleArn": {
"Fn::GetAtt": [
"TaskDefTaskRole1EDB4A67",
"Arn"
]
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/TaskDef/Resource"
}
},
"ServiceD69D759B": {
"Type": "AWS::ECS::Service",
"Properties": {
"Cluster": {
"Ref": "SampleClusterB4B72990"
},
"DeploymentConfiguration": {
"MaximumPercent": 200,
"MinimumHealthyPercent": 50
},
"DesiredCount": 2,
"EnableECSManagedTags": false,
"HealthCheckGracePeriodSeconds": 60,
"LaunchType": "FARGATE",
"LoadBalancers": [
{
"ContainerName": "DefaultContainer",
"ContainerPort": 8011,
"TargetGroupArn": {
"Ref": "LBListenerECSGroup1D445DF5"
}
}
],
"NetworkConfiguration": {
"AwsvpcConfiguration": {
"AssignPublicIp": "DISABLED",
"SecurityGroups": [
{
"Fn::GetAtt": [
"ServiceSecurityGroupC96ED6A7",
"GroupId"
]
}
],
"Subnets": [
{
"Ref": "SampleClusterVpcPrivateSubnet1Subnet24256A44"
},
{
"Ref": "SampleClusterVpcPrivateSubnet2Subnet25DCB36D"
}
]
}
},
"TaskDefinition": {
"Ref": "TaskDef54694570"
}
},
"DependsOn": [
"LBListenerECSGroup1D445DF5",
"LBListener49E825B4"
],
"Metadata": {
"aws:cdk:path": "CdkFargateStack/Service/Service"
}
},
"ServiceSecurityGroupC96ED6A7": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "CdkFargateStack/Service/SecurityGroup",
"SecurityGroupEgress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow all outbound traffic by default",
"IpProtocol": "-1"
}
],
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/Service/SecurityGroup/Resource"
}
},
"ServiceSecurityGroupfromCdkFargateStackLBSecurityGroupF16A57958011E231ABAF": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"IpProtocol": "tcp",
"Description": "Load balancer to target",
"FromPort": 8011,
"GroupId": {
"Fn::GetAtt": [
"ServiceSecurityGroupC96ED6A7",
"GroupId"
]
},
"SourceSecurityGroupId": {
"Fn::GetAtt": [
"LBSecurityGroup8A41EA2B",
"GroupId"
]
},
"ToPort": 8011
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/Service/SecurityGroup/from CdkFargateStackLBSecurityGroupF16A5795:8011"
}
},
"LB8A12904C": {
"Type": "AWS::ElasticLoadBalancingV2::LoadBalancer",
"Properties": {
"LoadBalancerAttributes": [
{
"Key": "deletion_protection.enabled",
"Value": "false"
}
],
"Scheme": "internet-facing",
"SecurityGroups": [
{
"Fn::GetAtt": [
"LBSecurityGroup8A41EA2B",
"GroupId"
]
}
],
"Subnets": [
{
"Ref": "SampleClusterVpcPublicSubnet1SubnetE377A512"
},
{
"Ref": "SampleClusterVpcPublicSubnet2SubnetB88D2B08"
}
],
"Type": "application"
},
"DependsOn": [
"SampleClusterVpcPublicSubnet1DefaultRoute28A82BC4",
"SampleClusterVpcPublicSubnet2DefaultRouteFD4087CF"
],
"Metadata": {
"aws:cdk:path": "CdkFargateStack/LB/Resource"
}
},
"LBSecurityGroup8A41EA2B": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Automatically created Security Group for ELB CdkFargateStackLBFC3A10CF",
"SecurityGroupIngress": [
{
"CidrIp": "0.0.0.0/0",
"Description": "Allow from anyone on port 80",
"FromPort": 80,
"IpProtocol": "tcp",
"ToPort": 80
}
],
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/LB/SecurityGroup/Resource"
}
},
"LBSecurityGrouptoCdkFargateStackServiceSecurityGroupB491C33C801194A30A9B": {
"Type": "AWS::EC2::SecurityGroupEgress",
"Properties": {
"GroupId": {
"Fn::GetAtt": [
"LBSecurityGroup8A41EA2B",
"GroupId"
]
},
"IpProtocol": "tcp",
"Description": "Load balancer to target",
"DestinationSecurityGroupId": {
"Fn::GetAtt": [
"ServiceSecurityGroupC96ED6A7",
"GroupId"
]
},
"FromPort": 8011,
"ToPort": 8011
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/LB/SecurityGroup/to CdkFargateStackServiceSecurityGroupB491C33C:8011"
}
},
"LBListener49E825B4": {
"Type": "AWS::ElasticLoadBalancingV2::Listener",
"Properties": {
"DefaultActions": [
{
"TargetGroupArn": {
"Ref": "LBListenerECSGroup1D445DF5"
},
"Type": "forward"
}
],
"LoadBalancerArn": {
"Ref": "LB8A12904C"
},
"Port": 80,
"Protocol": "HTTP"
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/LB/Listener/Resource"
}
},
"LBListenerECSGroup1D445DF5": {
"Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
"Properties": {
"Port": 8011,
"Protocol": "HTTP",
"TargetGroupAttributes": [
{
"Key": "stickiness.enabled",
"Value": "false"
}
],
"TargetType": "ip",
"VpcId": {
"Ref": "SampleClusterVpcD1C6ABD9"
}
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/LB/Listener/ECSGroup/Resource"
}
},
"CDKMetadata": {
"Type": "AWS::CDK::Metadata",
"Properties": {
"Analytics": "v2:deflate64:H4sIAAAAAAAA/31Ry27CMBD8Fu7GBSr1TilFSFUVJYhr5ThbumDWkR9BKMq/184D0lbqaWdn18nMzoLPZ3w2ERc7lcVpqjDndeaEPLFAfdQgLa9XylsHhq0+aYCvwhyEg52wpxf4REKHmuLCb0aTE0hgRlz/NgNToYT4qIcNA7ng9b6UkdwnK5b4XKHMfE7g2sUbSrWPv88V3Pk7t7RWSxSDqHYQwXqbxPIu3CYouIgrSwxWUcztw1sK/gIeFjolfbd04TRfZyDHMpDeoLtujPZlZ+I/YksHA9b+4dct3TAUZ16nurMTaziGEtahVFoUuVCCJNKhCvdZlmU4SmvuLcye21kXz49+vIchNep3Bjya70IkwfKgfNQ2DUvBam+6pMY4ZFu0iTaMdAH8aB+q+ROfP/LF5GgRp8aTwzPwtKvfgpQF22sCAAA="
},
"Metadata": {
"aws:cdk:path": "CdkFargateStack/CDKMetadata/Default"
},
"Condition": "CDKMetadataAvailable"
}
},
TEST
I am checking the log in in aws web console.
Cluster > AdminCluster > service: CdkFargateStack-ServiceD69D759B-cYrAHaRDN4mF
in event tab,
There are log like this
Service tries to start the task every one minutes.
TEST
ECS supports docker-compose style deployment.
So I try this with same image, then it works well
$docker context ls
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
desktop-linux moby unix:///Users/whitebear/.docker/run/docker.sock
docker-lamp-ecs ecs
$docker context use docker-lamp-ecs
$docker compose docker-compose.yml up
this deployment finished correctly container starts on ECS
However it fails in CDK.
SOLUTION
I found out the solution.
This could work
const adminRepo = ecr.Repository.fromRepositoryArn(this, 'AdminRepository', 'arn:aws:ecr:ap-northeast-1:678100XXXXXX:repository/st_admin_site')
const adminImage = ecs.ContainerImage.fromEcrRepository(adminRepo,"latest");
The previous code,
const adminImage = ecs.ContainerImage.fromRegistry('st_admin_site:latest')
it doesn't mean to get my ecrRepository....
I use ARN instead.
This is stupid mistakes.
However there is not the way to get the log.
So it takes long time to find out.
Thank you for your help.
I had some stacks that took more than 30 minutes in the past :D How long were you waiting ?
What was the resources part looking ? What was already created, what was still "in action" :) ?
Did something crashed while creating and was in multiple retries ?
Not much information to really know what's happening, but IIRC if your container fails to start it will fail to create the ECS service. You can check if the service was actually created in the ECS console, and if it exists, check the event log to see if they aren't failing. If they are failing, you can check the reason in the task.

not able to notarize electron app using forge

hello I am building electron app for the mac platform and having trouble notarize the app using Forge and getting this error:
Packaging ApplicationWARNING: Code sign failed; please retry manually. Error: Command failed: spctl --assess --type execute --verbose --ignore-cache --no-cache /var/folders/q7//T/electron-packager/darwin-arm64/Integration-darwin-arm64/Integration.app
/var/folders/q7/*/T/electron-packager/darwin-arm64/Integration-darwin-arm64/Integration.app: rejected
source=Unnotarized Developer ID
my forge config
"forge": {
"packagerConfig": {
"appBundleId": "com.anyfolder.integrations",
"osxSign": {
"identity": "Developer ID Application: ****** (****)",
"hardened-runtime": true,
"entitlements": "entitlements.plist",
"entitlements-inherit": "entitlements.plist",
"signature-flags": "library"
},
"osxNotarize": {
"appleId": "myid#id.com",
"appleIdPassword": "my-password"
},
"protocols": [
{
"name": "Any Folder",
"schemes": [
"electron-****"
]
}
],
"icon": "public/images/icon.ico"
},
"publishers": [
{
"name": "#electron-forge/publisher-s3",
"config": {
"bucket": "*******",
"folder": "integrations",
"public": true
}
},
{
"name": "#electron-forge/publisher-github",
"config": {
"repository": {
"owner": "****",
"name": "****"
},
"draft": false,
"prerelease": false
}
}
],
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "integrations"
}
},
{
"name": "#electron-forge/maker-dmg",
"config": {
"icon": "public/images/icon.icns",
"format": "ULFO",
"name": "Name",
"overwrite": true,
"debug": true
}
}
],
"plugins": [
[
"#electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/render/imageEditor/index.html",
"js": "./src/render/imageEditor/index.tsx",
"name": "capture_window",
"preload": {
"js": "./src/render/imageEditor/preload.ts"
}
},
{
"name": "main_window",
"html": "./src/index.html",
"js": "./src/render/main/index.tsx",
"preload": {
"js": "./src/render/main/preload.ts"
}
},
{
"name": "integrations_menu",
"html": "./src/index.html",
"js": "./src/render/integrations/index.tsx",
"preload": {
"js": "./src/render/integrations/preload.ts"
}
}
]
}
}
]
]
}

elastic search parsing_exception for boost query

I'm trying to boost up the query using elastic search. Headlines that are published recently must be boosted up and should come on top. However, I have return the following code:
{
"query": {
"function_score": {
"query": {
"bool": {
"must": {
"match": {
"keywords": {
"query":"trump"
}
}
},
"should": [
{ "match": {
"type": {
"query": "headline"
}
}}
]}},
"functions": [
{ "boost": 5 },
{
"gauss": {
"versioncreated": {
"origin": "now/d",
"scale": "50w",
"offset": "4w",
"decay": "0.5"
}}}],
"score_mode": "sum"
}
}}
I'm getting this error :-
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "no [score_function] registered for [params]",
"line": 24,
"col": 20
}
],
"type": "parsing_exception",
"reason": "no [score_function] registered for [params]",
"line": 24,
"col": 20
},
"status": 400
}
You query is a bit wrong. What do you want do by this?
"functions": [
{ "boost": 5 },
If you want to boost it try to use this query
{
"query": {
"function_score": {
"query": {
"bool": {
"must": {
"match": {
"keywords": {
"query": "trump"
}
}
},
"should": [
{
"match": {
"type": {
"query": "headline"
}
}
}
]
}
},
"functions": [
{
"gauss": {
"versioncreated": {
"origin": "now/d",
"scale": "50w",
"offset": "4w",
"decay": "0.5"
}
}
}
],
"boost": 5,
"score_mode": "sum"
}
}
}

What is the RootElement of this Content

I'm trying to use the TRESTResponseDataSetAdapter.
Every combination that I've tried for the JSON RootElement property fails
You can view the content by running this in your browser:
https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=Demo&count=1000
{
"contacts":[
{
"addedAt":1405347851360,
"vid":154835,
"canonical-vid":154835,
"merged-vids":[
],
"portal-id":62515,
"is-contact":true,
"profile-token":"AO_T-mMn77ArlMSBCTdpOp0rf0qYYooZ7bHB6ehvufx9uNoV0Pyuiq1wq-A83BQmzFVFVC45T8S6tXhkq_7fcDi5Wzne7VXydwTvrKIViisZNBjWhUjJ8OiXhXW0owESlE2QCh2_rZsy",
"profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMn77ArlMSBCTdpOp0rf0qYYooZ7bHB6ehvufx9uNoV0Pyuiq1wq-A83BQmzFVFVC45T8S6tXhkq_7fcDi5Wzne7VXydwTvrKIViisZNBjWhUjJ8OiXhXW0owESlE2QCh2_rZsy/",
"properties":{
"firstname":{
"value":"HubSpot"
},
"lastmodifieddate":{
"value":"1429569233340"
},
"lastname":{
"value":"Test"
}
},
"form-submissions":[
{
"conversion-id":"b18f9fd8-b8d3-49e5-898a-ac301fac93e9",
"timestamp":1405347851180,
"form-id":"b844ad5e-32bd-41e1-b0e6-ed990c5f3d1b",
"portal-id":62515,
"page-url":"http://demo.hubapi.com/your-stunning-headline-30",
"page-title":"Your stunning headline!",
"page-id":"324527",
"title":"My New Form",
"meta-data":[
]
}
],
"identity-profiles":[
{
"vid":154835,
"saved-at-timestamp":1405347851237,
"deleted-changed-timestamp":0,
"identities":[
{
"type":"EMAIL",
"value":"test#hubspot.com",
"timestamp":1405347851180
},
{
"type":"LEAD_GUID",
"value":"c8f20860-d3d6-4b57-b092-86a07cebdcbc",
"timestamp":1405347851237
}
]
}
],
"merge-audits":[
]
},
{
"addedAt":1390569372731,
"vid":196181,
"canonical-vid":196181,
"merged-vids":[
],
"portal-id":62515,
"is-contact":true,
"profile-token":"AO_T-mNWKZQBRv0UiQpPnG-WPBgVlfYwFgdTyJW3sU9frlA4esRYMOtMpo4OQMh736HGvJpuDLAuJexFXkyrIPu7eK-hxFYwGoqefbbP1cQeh6B0mRPE-iU1dhYRhRJsWyroaToFvFuo",
"profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mNWKZQBRv0UiQpPnG-WPBgVlfYwFgdTyJW3sU9frlA4esRYMOtMpo4OQMh736HGvJpuDLAuJexFXkyrIPu7eK-hxFYwGoqefbbP1cQeh6B0mRPE-iU1dhYRhRJsWyroaToFvFuo/",
"properties":{
"firstname":{
"value":"Charles"
},
"lastmodifieddate":{
"value":"1429569231725"
},
"company":{
"value":""
},
"lastname":{
"value":"Gowland"
}
},
"form-submissions":[
],
"identity-profiles":[
{
"vid":196181,
"saved-at-timestamp":1390569372649,
"deleted-changed-timestamp":0,
"identities":[
{
"type":"EMAIL",
"value":"clg#gburnette.com",
"timestamp":1390568711002
},
{
"type":"LEAD_GUID",
"value":"dca0d8a2-fa9c-4ca6-b5ef-c1bfb4a0bed4",
"timestamp":1390569372636
}
]
}
],
"merge-audits":[
]
},
{
"addedAt":1390569372834,
"vid":196182,
"canonical-vid":196182,
"merged-vids":[
],
"portal-id":62515,
"is-contact":true,
"profile-token":"AO_T-mPTJ_EIS2780cJONDGKv5bmchukJnQ37QmmSc-lPJacEyzXo8piybhaAhQzT0HBXxq0QYXFU_4wN5ewYsclTt8WE3KAxx6neusNNYGr8aEiy-s6izAG-CCehTdomM5Pai4YOKue",
"profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mPTJ_EIS2780cJONDGKv5bmchukJnQ37QmmSc-lPJacEyzXo8piybhaAhQzT0HBXxq0QYXFU_4wN5ewYsclTt8WE3KAxx6neusNNYGr8aEiy-s6izAG-CCehTdomM5Pai4YOKue/",
"properties":{
"firstname":{
"value":"Curtis"
},
"lastmodifieddate":{
"value":"1429569238098"
},
"company":{
"value":""
},
"lastname":{
"value":"Romig"
}
},
"form-submissions":[
],
"identity-profiles":[
{
"vid":196182,
"saved-at-timestamp":1390569372699,
"deleted-changed-timestamp":0,
"identities":[
{
"type":"EMAIL",
"value":"curtis.romig#bryancave.com",
"timestamp":1390568725415
},
{
"type":"LEAD_GUID",
"value":"e18dc184-0238-48f1-a8a2-4476733f50d3",
"timestamp":1390569372641
}
]
}
],
"merge-audits":[
]
},
{
"addedAt":1390569372757,
"vid":196183,
"canonical-vid":196183,
"merged-vids":[
],
"portal-id":62515,
"is-contact":true,
"profile-token":"AO_T-mOq49asR9pF4P9paqXhVApLjs9CXDFqCFs4BL7Y5z7TRYRoSC9i8cXxGOdXZqC-3D1doXT5G-pmAG283AFo0BYY3D-1AV2VhwIlVZ3t1KF-6G7DBQw80lRqBjPbJhtLnY7U6rd-",
"profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mOq49asR9pF4P9paqXhVApLjs9CXDFqCFs4BL7Y5z7TRYRoSC9i8cXxGOdXZqC-3D1doXT5G-pmAG283AFo0BYY3D-1AV2VhwIlVZ3t1KF-6G7DBQw80lRqBjPbJhtLnY7U6rd-/",
"properties":{
"firstname":{
"value":"Eugene"
},
"lastmodifieddate":{
"value":"1429569256338"
},
"company":{
"value":""
},
"lastname":{
"value":"Klibanoff"
}
},
"form-submissions":[
],
"identity-profiles":[
{
"vid":196183,
"saved-at-timestamp":1390569372682,
"deleted-changed-timestamp":0,
"identities":[
{
"type":"EMAIL",
"value":"eklibanoff#incomm.com",
"timestamp":1390568722786
},
{
"type":"LEAD_GUID",
"value":"276f1a0f-ce8f-4069-9b7a-405f9e14971a",
"timestamp":1390569372674
}
]
}
],
"merge-audits":[
]
},
{
"addedAt":1390569372800,
"vid":196184,
"canonical-vid":196184,
"merged-vids":[
],
"portal-id":62515,
"is-contact":true,
"profile-token":"AO_T-mMay6vd3gbNXXOGGn7WYa4332kjWEY6hYvggd98z-MYeHHaXL8BqAHSmsGQ1VVuN9_JOUPlqQ5ZC4e0-fNjOqj-yNp23nsqldKBYY0WF-m5pgnOGEwXEV2eLNVJmFffQ0U3SXXL",
"profile-url":"https://app.hubspot.com/contacts/62515/lists/public/contact/_AO_T-mMay6vd3gbNXXOGGn7WYa4332kjWEY6hYvggd98z-MYeHHaXL8BqAHSmsGQ1VVuN9_JOUPlqQ5ZC4e0-fNjOqj-yNp23nsqldKBYY0WF-m5pgnOGEwXEV2eLNVJmFffQ0U3SXXL/",
"properties":{
"firstname":{
"value":"James C. & Brenda L."
},
"lastmodifieddate":{
"value":"1429569255451"
},
"company":{
"value":""
},
"lastname":{
"value":"Kellling"
}
},
"form-submissions":[
],
"identity-profiles":[
{
"vid":196184,
"saved-at-timestamp":1390569372744,
"deleted-changed-timestamp":0,
"identities":[
{
"type":"EMAIL",
"value":"jameskelling#bellsouth.net",
"timestamp":1390568911277
},
{
"type":"LEAD_GUID",
"value":"4b92ccc6-d777-4e3e-90d9-bc4722329c16",
"timestamp":1390569372738
}
]
}
],
"merge-audits":[
]
}
],
"has-more":true,
"vid-offset":196184
}
I'm trying to build a ClientDataSet that includes Company, FirstName, LastName and EMAIL
Can someone please view the content and identify the correct RootElement for me ?
There is no plug-and-play way for this kind of data structure to map inside a TClientDataSet.
The mapping can be done by TRESTResponseDataSetAdapter on an array of objects like this
[
{
"firstname": "John",
"lastname": "Doe",
"email": "john#doe.com"
},
{
"firstname": "Jane",
"lastname": "Doe",
"email": "jane#doe.com"
}
]
or even nested
{
"contacts": [
{
"firstname": "John",
"lastname": "Doe",
"email": "john#doe.com"
},
{
"firstname": "Jane",
"lastname": "Doe",
"email": "jane#doe.com"
}
]
}
when you set the RootElement property to contacts.
But not with this kind of nested structure you are getting from your REST API.
You have to know the structure and map that by hand

Resources