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

abundant-umbrella-49346

03/09/2024, 2:21 AM
Good morning. Using python, I am trying to run this commands as user data after EC2 instances run. It seems like the machine cannot recognize the pull and run commands as they are with "{ecr_repository.url}" not its value. my questions are: 1. Can this script be edited so that pull and push can work? 2. I am not sure why the created images always have the tag of 4xxxxxxx-container, how to control or change that to "latest"?
I have managed to answer question 1. Still not able to answer question 2 which is marked by red lines
s

stale-twilight-75626

03/09/2024, 7:44 AM
Are you pushing the :latest tag when you push the images to the registry?
a

abundant-umbrella-49346

03/09/2024, 7:46 AM
Not exactly, I am creating an image and its tagged by default with: 46186468-container. always the same tag even after executing pulumi up and down multiple times. I dont know the reason or meaning of the number and I can't change it
s

stale-twilight-75626

03/09/2024, 7:56 AM
it might have something to do with auto naming
pulumi ai thinks this will work:
Copy code
# Build and publish the Docker image to the ECR repository
image = awsx.ecr.Image("myapp",
    repository_url=repo.repository_url,
    path=docker_build_context_path,
    tags={"latest": None}  # Tag the image as 'latest'
)
a

abundant-umbrella-49346

03/09/2024, 8:01 AM
Yeah GPT is limited in this part, there's no parameter called tags.
s

stale-twilight-75626

03/09/2024, 8:01 AM
yeah I'm looking at the docs and I don't see it there
welllll
it's not great but you could output the variable of the image
then write a script to read that image in, add the latest tag, and push
a

abundant-umbrella-49346

03/09/2024, 8:04 AM
I am trying to avoid that so far 😆
s

stale-twilight-75626

03/09/2024, 8:04 AM
or in the EC2 startup script, pull down the image and tag
a

abundant-umbrella-49346

03/09/2024, 8:04 AM
and tag? how is that?
s

stale-twilight-75626

03/09/2024, 8:05 AM
I'm thinking there might be a way to output the image:tag with pulumi and have it up on pulumi cloud
then the ec2 bootstrap script could pull from it
but
why are you doing this anyway? lol
you can spin up a docker image lots of places that are probably easier to interact with
a

abundant-umbrella-49346

03/09/2024, 8:11 AM
I am trying a simple app, creating an image for it and push it to an ECR repo, then using application load balancer with listener and target group by auto scaling attachment, launch configuration, auto scaling, IAM roles, security groups and I have tried to create a cloudwatch dashboard from the code using some metrics but its not doing well so i'll skip it. What I did with the tag is hardcoding so there must be a way to avoid that
s

stale-twilight-75626

03/09/2024, 8:14 AM
the awsx package is opinionated so I would consider using the advantages that gives you (https://www.pulumi.com/docs/clouds/aws/guides/ecs/ )
a

abundant-umbrella-49346

03/09/2024, 8:16 AM
Using ECS is a different and easier approach, but I was trying these as a POC for me to know the limitations and understand the capabilities
Not all the scenarios should use ECS, that's another point
s

stale-twilight-75626

03/09/2024, 8:19 AM
yeah you are going to run into limitations once APIs don't exist to perform tasks
there is an API to spin up an EC2 instance, but after that the AWS API can't do much to it except power it up and delete it
but there are APIs to spin up containers on ECS or a K8 cluster so you're going to have an easier time
a

abundant-umbrella-49346

03/09/2024, 8:21 AM
I am trying to use nomad, a hard combination but doable, still on it
s

stale-twilight-75626

03/09/2024, 8:23 AM
Hashicorp makes some good stuff, I'm sure you'll be fine
I'm off to bed - best of luck Ali
a

abundant-umbrella-49346

03/09/2024, 8:25 AM
Thanks Doug, goodnight
I have fixed point "2" through this, didnt think it was possible at first