https://pulumi.com logo
#general
Title
# general
h

high-morning-18773

10/22/2019, 7:54 PM
Hello, i am not able to figure out how to properly create containerdefinition json file in pulumi(using python), when creating ecs fargate task definition. i stored json values as list in a variable wrote and function that returns json And then set containerdefinition = generatejsob object, but that does not seems to work. i get this error
Copy code
raise TypeError(f'Object of type {o.__class__.__name__} '
    TypeError: Object of type Output is not JSON serializable
.
w

white-balloon-205

10/22/2019, 7:57 PM
Can you share the code snippet of how you pass
container_definition
?
h

high-morning-18773

10/22/2019, 8:02 PM
Copy code
containerdeflist = [{
  "ipcMode": 'null',
  "executionRoleArn": "reacted",
  "containerDefinitions": [
    {
      "dnsSearchDomains": [],
      "logConfiguration": {
        "logDriver": "awslogs",
        "secretOptions": [],
        "options": {
          "awslogs-group": "redacted",
          "awslogs-region": "us-west-2",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "entryPoint": [],
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        },
        {
          "hostPort": 443,
          "protocol": "tcp",
          "containerPort": 443
        },
        {
          "hostPort": 3000,
          "protocol": "tcp",
          "containerPort": 3000
        }
      ],
      "command": [],
This is just a snippet 
}]
Copy code
containerstring=createcdef(containerdeflist)
Copy code
task = aws.ecs.TaskDefinition(
    "test-task",
    container_definitions=[containerstring],

)
Copy code
def createcdef(containerdeflist):
    return json.dumps(containerdeflist)
Maybe I am doing this all wrong. Any help is appreciated.
I figured out the issue had to read up documentation again my containerdefinition was wrong this link was helpful
Copy code
<https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html>
Thanks for looking into this
3 Views