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

witty-spring-28765

05/23/2020, 9:54 AM
Hello All, I am trying to acheive the following. Please let me know if this is possible 1. Create a python docker using pulumi 2. Deploy this docker image on to an EC2 instance can this be done is the same script or is it better to use a different CI/CD for the docker build and a separate one for Infra build.
b

broad-dog-22463

05/23/2020, 11:18 AM
Hi @witty-spring-28765 This can indeed be done with Pulumi - https://github.com/pulumi/examples/tree/master/aws-py-fargate
That should get you some of the way - the docker build and the ECR repo. Then you would need to pass the docker container name to a userdata script on an instance and run your docker pill and run commands there
This example will show you how to pass userdata https://github.com/pulumi/examples/tree/master/aws-py-webserver
w

witty-spring-28765

05/23/2020, 12:40 PM
Hello Paul, many thanks for the response. The fargate example provided gets the image from an ECR. But I am trying to keep the docker code build and the deployment in the same stack of pulumi. Or do I have to have two separate items? I found this example https://github.com/pulumi/pulumi-docker/blob/master/examples/aws-py but this seems to be focused on ECR, is there no integration to push builds to dockerhub for example?
b

broad-dog-22463

05/23/2020, 2:23 PM
Oh I apologise - I didn’t realise that wasn’t in the example
One second
This will show you how to use Pulumi to build the container
And as part of that repository you can push to ECR
w

witty-spring-28765

05/23/2020, 9:04 PM
thanks Paul, but just running this example without changes, where does the image get pushed to the pulumi app ?
b

broad-dog-22463

05/23/2020, 10:32 PM
By default it will keep the image local due to SkipPush: true
But you can look at the api and see that it allows you to push to a registry @witty-spring-28765
w

witty-spring-28765

05/25/2020, 7:00 PM
Thanks Paul, it work like a charm. Is there a way to avoid the SHA being tagged to ECR