Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python / GCP] 404 when trying to create gcp.cloudrun.IamMember #611

Closed
karolzlot opened this issue Jul 7, 2021 · 5 comments
Closed

[Python / GCP] 404 when trying to create gcp.cloudrun.IamMember #611

karolzlot opened this issue Jul 7, 2021 · 5 comments
Labels
kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed

Comments

@karolzlot
Copy link

Steps to reproduce

Create new Google Cloud project and deploy this Pulumi code. It works ok.

import pulumi
import pulumi_gcp as gcp


region= "us-central1"

# Cloud Run Service is not enabled by default, let's enable it
enableCloudRun = gcp.projects.Service("EnableCloudRun",
    service= "run.googleapis.com",
)


cloud_run_hello_service = gcp.cloudrun.Service("hello-service",
    location=region,  # Google Cloud Region
    template=gcp.cloudrun.ServiceTemplateArgs(
        spec=gcp.cloudrun.ServiceTemplateSpecArgs(
            containers=[gcp.cloudrun.ServiceTemplateSpecContainerArgs(
                image="us-docker.pkg.dev/cloudrun/container/hello", # "Hello-world" container
            )],
        ),
    ),
    traffics=[gcp.cloudrun.ServiceTrafficArgs( # this just sets traffic 100% to our app
        latest_revision=True,
        percent=100,  
    )],
    opts=pulumi.ResourceOptions(depends_on=[enableCloudRun]) # this line tells Pulumi that Cloud Run service requires enabled Cloud Run API
    )  



pulumi.export("cloud_run_url", cloud_run_hello_service.statuses[0].url)

  1. Add this code and try to deploy (pulumi up)
hello_service_iam_member = gcp.cloudrun.IamMember("hello_service_iam_member",
    service= cloud_run_hello_service.name,
    role= "roles/run.invoker",
    member= "allUsers")


Expected:

It should be deployed ok and allow me to reach Cloud Run service by its URL.

This is what I am trying to do, but code from this article is in Typescript: https://www.pulumi.com/blog/google-cloud-run-serverless-containers/


Actual:

 pulumi up
Previewing update (dev)

View Live: https://app.pulumi.com/karolzlot/quickstart5/dev/previews/55519749-7b61-47c9-92bd-22fb4345c0ff

     Type                       Name                      Plan
     pulumi:pulumi:Stack        quickstart5-dev
 +   └─ gcp:cloudrun:IamMember  hello_service_iam_member  create

Resources:
    + 1 to create
    3 unchanged

Do you want to perform this update? yes
Updating (dev)

View Live: https://app.pulumi.com/karolzlot/quickstart5/dev/updates/28

     Type                       Name                      Status                  Info
     pulumi:pulumi:Stack        quickstart5-dev           **failed**              1 error
 +   └─ gcp:cloudrun:IamMember  hello_service_iam_member  **creating failed**     1 error

Diagnostics:
  pulumi:pulumi:Stack (quickstart5-dev):
    error: update failed

  gcp:cloudrun:IamMember (hello_service_iam_member):
    error: 1 error occurred:
        * Error retrieving IAM policy for cloudrun service "v1/projects/pulumi-test-project-123/locations//services/hello-service-4190926": googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
    <html lang=en>
      <meta charset=utf-8>
      <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
      <title>Error 404 (Not Found)!!1</title>
      <style>
        *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
      </style>
      <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
      <p><b>404.</b> <ins>That’s an error.</ins>
      <p>The requested URL <code>/v1/projects/pulumi-test-project-123/locations//services/hello-service-4190926:getIamPolicy</code> 
was not found on this server.  <ins>That’s all we know.</ins>

Outputs:
    cloud_run_url: "https://hello-service-4190926-r36rc2cfua-uc.a.run.app"

Resources:
    3 unchanged

Duration: 2s
@karolzlot
Copy link
Author

Possible duplicate to https://github.com/pulumi/pulumi/issues/7439

@stack72
Copy link
Contributor

stack72 commented Jul 7, 2021

Hi @karolzlot

What version of pulumi-gcp are you using? I can't recreate this using the latest version

Paul

@stack72 stack72 transferred this issue from pulumi/pulumi Jul 7, 2021
@karolzlot
Copy link
Author

@stack72

I installed pulumi in last few days.

pip freeze
Arpeggio==1.10.2
attrs==21.2.0     
dill==0.3.4       
grpcio==1.38.1    
parver==0.3.1     
protobuf==3.17.3  
pulumi==3.6.0     
pulumi-gcp==5.11.0
PyYAML==5.4.1     
semver==2.13.0    
six==1.16.0       

I checked now again, and I still have this error.

@karolzlot
Copy link
Author

karolzlot commented Jul 7, 2021

@stack72
If it helps I can add you to this Google Cloud project, I created it yesterday only for learning purposes.

@mikhailshilkov mikhailshilkov added the kind/bug Some behavior is incorrect or out of spec label Jan 30, 2023
@mikhailshilkov mikhailshilkov added the resolution/fixed This issue was fixed label Oct 27, 2023
@mikhailshilkov mikhailshilkov self-assigned this Oct 27, 2023
@mikhailshilkov mikhailshilkov added resolution/by-design This issue won't be fixed because the functionality is working as designed and removed resolution/fixed This issue was fixed labels Oct 27, 2023
@mikhailshilkov mikhailshilkov removed their assignment Oct 27, 2023
@mikhailshilkov
Copy link
Member

It looks like a location was not specified in this example. I think you have to set it explicitly:

hello_service_iam_member = gcp.cloudrun.IamMember("hello_service_iam_member",
    service= cloud_run_hello_service.name,
    location= cloud_run_hello_service.location,
    role= "roles/run.invoker",
    member= "allUsers")

and then it works for me.

I agree we could provide a better validation and error message, but that's largely on the upstream provider, there isn't much we can do.

Since the issue is quite old and I tested the resource, I'll go ahead and close it. Please open a new one if anybody still has troubles here.

@mikhailshilkov mikhailshilkov closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/by-design This issue won't be fixed because the functionality is working as designed
Projects
None yet
Development

No branches or pull requests

3 participants