Hey everybody my firm is new to pulumi and I'm try...
# python
r
Hey everybody my firm is new to pulumi and I'm trying to do some simple stuff with it to get the hang of it. Im trying to push a container to ecr and then supply that container name to the task definition, which clearly requires a JSON serializable string. what is the best way to do that. everything i try is of type Output. Much thanks community!
Copy code
task_definition = aws.ecs.TaskDefinition('slt-task',
    family='fargate-task-definition',
    cpu='256',
    memory='512',
    network_mode='awsvpc',
    requires_compatibilities=['FARGATE'],
    execution_role_arn=role.arn,
	container_definitions=json.dumps([{
		'name': 'slt-rec',
		'image': 'IMAGE_NAME' ,
		'portMappings': [{
			'containerPort': 8501,
			'hostPort': 8501,
			'protocol': 'tcp'
		}]
	}]),
	opts=ResourceOptions(depends_on=[image]), # unsure here
)
g
Because the image name is an Output (you can also think of this a Promise or "future value"), you need to use a special function to tell Pulumi to wait for this value to be available before constructing the JSON string. The documentation on Output is here - https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs And here is an example with ECS TaskDefintion - https://github.com/pulumi/examples/blob/f0732dc6314636f48a88b4ac4da55e3187b1def4/aws-py-voting-app/__main__.py#L260-L275.
r
thats clarifying! thanks!