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

miniature-dentist-28288

03/18/2023, 12:53 AM
How do I ensure that a new CloudRun revision is created whenever an image is updated? I’m using CloudRunv2 and have the set up below.
Copy code
# Create a container image for the service.
image = docker.Image(
    "backend-image",
    image_name=f"{location}-docker.pkg.dev/{project}/{repo_id}/{image_name}",
    build=docker.DockerBuildArgs(
        context=".",
        dockerfile="Dockerfile",
    ),
    opts=pulumi.ResourceOptions(
        parent=backend_repo,
        depends_on=[backend_repo],
    ),
)

# Create a Cloud Run service definition.
service = cloudrun.Service(
    "service",
    opts=pulumi.ResourceOptions(
        parent=image,
        depends_on=[image],
    ),
    location=location,
    ingress="INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER",
    template=cloudrun.ServiceTemplateArgs(
        containers=[
            cloudrun.ServiceTemplateContainerArgs(
                image=image.image_name,
                resources=cloudrun.ServiceTemplateContainerResourcesArgs(
                    limits=dict(
                        memory=memory,
                        cpu=cpu,
                    ),
                ),
                ports=[
                    cloudrun.ServiceTemplateContainerPortArgs(
                        container_port=container_port,
                    ),
                ],
            ),
        ],
        scaling=cloudrun.ServiceTemplateScalingArgs(
            max_instance_count=5,
            min_instance_count=1,
        ),
    ),
)
4 Views