This message was deleted.
# general
s
This message was deleted.
c
You can use the pulumi.Import option and specify the GCP ID of the resource. In this example I do it with a keyring:
Copy code
ring, err := kms.NewKeyRing(ctx, "keyring-name", &kms.KeyRingArgs{
		Location: pulumi.Sprintf("global"),
		Name:     pulumi.Sprintf("keyring-name"),
	}, pulumi.Import(pulumi.ID("projects/<project_id>/locations/global/keyRings/<keyring-name>")))
But, I'm unsure if this applies to your use case, but you do import the resource and pulumi will apply the argument values with whatever diffs to the resource
m
Thanks Simon! And how would you use that import functionality to force a replace just once when running
pulumi up
?
Read a bit more about import and it’s not applicable here. So please, disregard that previous question 😅
👀 1
So in my particular case I think the problem is that my Cloud Run Service doesn’t recognize the image has updated because I’m using the tag latest. So I guess I’ll have to instead generate a new tag whenever the contents of the image change.
c
Aah, yes. I use the commit short-hash as tag for containers in cloudrun, it's clean and you can reference the container to a commit.
Are you using pulumi for deploying new builds, or are you using the build system (e.g cloudbuild) to deploy new containers separately from pulumi? I'm having another problem with images for cloudrun https://pulumi-community.slack.com/archives/CRFUR2DGB/p1607548495073900 Figure you might run into it as well, unless you exclusively deploy with pulumi. Curious to hear your approach for deployment.
m
Yeah, I think I have kind of the opposite problem, where I’m trying to build the image locally, push it to gcr and then have cloudrun update the service.
1
So currently I’m building the image locally using a Docker Image resource
Copy code
cloudrun_service_image = Image(
	"service_image",
	image_name=f'<http://eu.gcr.io/{project}/my-service/{environment}-my-service|eu.gcr.io/{project}/my-service/{environment}-my-service>',
	build=DockerBuild(context=f'./cloudrun/')
)
👍 1
I’m open to using CloudBuild as well, but in my current setup I’d prefer building the image from the local code instead of the repo.
I know gcr will autogenerate a unique id for every build, but I’m struggling to decide if I want to get that or try to construct a hash of the contents of the image locally.
Any pointers?
c
cloudbuild would probably be overkill if the purpose is to generate a tag. I guess you're going for fast builds locally that may or may not belong to a git commit? Maybe you could get content hash from the src folder?
m
Yeah, that’s probably the way to go for now
c
Can't you tag the Image resource based on content of container before you deploy it to cloudrun_service_image? 🙂
m
Yeah, that’s probably they way to go. I was just hoping for some shortcut and not having to program the logic myself 😬
It’s working. A related question, is there something like the terraform null resource in pulumi?
🙌 1