I'm getting this error: `aws:ecr/getCredentials:ge...
# localstack
r
I'm getting this error:
aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF
I have a project that is attempting to put an image into localstack's
aws:ecr
However, the ecr is, for some reason, calling
getCredentials
? Is there a way to stub this out so it doesn't need to make this call? REPRO:
Copy code
cd {existing project}
pulumilocal init
# remove the line with mobileanalytics in the Pulumi.localstack.yml file
pulumilocal up
CODE:
Copy code
import os

import pulumi_awsx as awsx
from utils import resource_utils

# create an ecr repository in aws
repo = awsx.ecr.Repository(
    resource_utils.get_name(awsx.ecr.Repository),
    tags=resource_utils.tags(),
)

# create an image and deploy to that repository
image = awsx.ecr.Image(
    resource_utils.get_name(awsx.ecr.Image),
    repository_url=repo.url,
    path=os.path.join(os.path.dirname(__file__), "..", "..", "docker", "_build"),
)
ERROR:
Copy code
View Live: <https://app.pulumi.com/ToddG/component-project/localstack/updates/2>

     Type                  Name                                                       Status              Info
     pulumi:pulumi:Stack   component-project-localstack                               **failed (1s)**     2 errors; 2 warnings; 34 messages
 +   ├─ aws:kms:Alias      localstack-component-project-kms-alias                     created (0.15s)     
 +   └─ aws:ssm:Parameter  /localstack/component/backend_project_microservice/db_uri  created (0.67s)     


Diagnostics:
  pulumi:pulumi:Stack (component-project-localstack):
    warning: provider config warning: Use s3_use_path_style instead.
    warning: provider config warning: Argument is deprecated
    dockerBuild: {"context":"/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/./resources/../../docker/_build"}
    error: Error: invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF
        at Object.callback (/snapshot/awsx/node_modules/@pulumi/pulumi/runtime/invoke.js:141:33)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client.ts:338:26)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client-interceptors.ts:426:34)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client-interceptors.ts:389:48)
        at /snapshot/awsx/node_modules/@grpc/grpc-js/src/call-stream.ts:276:24
        at processTicksAndRejections (node:internal/process/task_queues:78:11)
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/resource.py", line 608, in do_rpc_call
        return monitor.RegisterResource(req)
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/grpc/_channel.py", line 946, in __call__
        return _end_unary_response_blocking(state, call, False, None)
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
        raise _InactiveRpcError(state)
    grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    	status = StatusCode.UNKNOWN
    	details = "invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF"
    	debug_error_string = "{"created":"@1668557391.399938162","description":"Error received from peer ipv4:127.0.0.1:40907","file":"src/core/lib/surface/call.cc","file_line":966,"grpc_message":"invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF","grpc_status":2}"
    >
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/todd/.pulumi/bin/pulumi-language-python-exec", line 192, in <module>
        loop.run_until_complete(coro)
      File "/home/todd/.pyenv/versions/3.10.6/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
        return future.result()
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 126, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
        await wait_for_rpcs()
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/stack.py", line 110, in wait_for_rpcs
        raise exception
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/rpc_manager.py", line 68, in rpc_wrapper
        result = await rpc
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/resource.py", line 613, in do_register
        resp = await asyncio.get_event_loop().run_in_executor(None, do_rpc_call)
      File "/home/todd/.pyenv/versions/3.10.6/lib/python3.10/concurrent/futures/thread.py", line 58, in run
        result = self.fn(*self.args, **self.kwargs)
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/resource.py", line 610, in do_rpc_call
        handle_grpc_error(exn)
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/settings.py", line 273, in handle_grpc_error
        raise grpc_error_to_exception(exn)
    Exception: invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF

    panic: runtime error: index out of range [0] with length 0
    goroutine 83 [running]:
    <http://github.com/hashicorp/terraform-provider-aws/internal/service/ecr.dataSourceAwsEcrCredentialsRead(0xc00232fd80|github.com/hashicorp/terraform-provider-aws/internal/service/ecr.dataSourceAwsEcrCredentialsRead(0xc00232fd80>, {0x7e70e80, 0xc000dc1500})
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-provider-aws@v1.38.1-0.20220425115028-72c3a67ae4a7/internal/service/ecr/credentials_data_source.go:59 +0x3f6
    <http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x9254241|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x9254241>, {0xa33b938, 0xc0000520f8}, 0x7e70e80, {0x7e70e80, 0xc000dc1500})
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20211230170131-3a7c83bfab87/helper/schema/resource.go:336 +0x178
    <http://github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc000d5f520|github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc000d5f520>, {0xa33b938, 0xc0000520f8}, 0xc00232fd00, {0x7e70e80, 0xc000dc1500})
    	/home/runner/go/pkg/mod/github.com/pulumi/terraform-plugin-sdk/v2@v2.0.0-20211230170131-3a7c83bfab87/helper/schema/resource.go:559 +0xf7
    <http://github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.ReadDataApply({0xa49c048}|github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2.v2Provider.ReadDataApply({0xa49c048}>, {0x92ad3eb, 0x13}, {0xa43f688, 0xc00232fd00})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.22.1/pkg/tfshim/sdk-v2/provider.go:143 +0xc5
    <http://github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Invoke(0xc0006a78c0|github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge.(*Provider).Invoke(0xc0006a78c0>, {0xa33b9a8, 0xc00239e330}, 0xc00238a6c0)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi-terraform-bridge/v3@v3.22.1/pkg/tfbridge/provider.go:1187 +0x799
    <http://github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler.func1({0xa33b9a8|github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler.func1({0xa33b9a8>, 0xc00239e330}, {0x8d92900, 0xc00238a6c0})
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.31.1/proto/go/provider.pb.go:2521 +0x7b
    <http://github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0xa33b9a8|github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc.OpenTracingServerInterceptor.func1({0xa33b9a8>, 0xc00239e0c0}, {0x8d92900, 0xc00238a6c0}, 0xc0018b5ae0, 0xc002398420)
    	/home/runner/go/pkg/mod/github.com/grpc-ecosystem/grpc-opentracing@v0.0.0-20180507213350-8e809c8a8645/go/otgrpc/server.go:57 +0x406
    <http://github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler({0x90f7860|github.com/pulumi/pulumi/sdk/v3/proto/go._ResourceProvider_Invoke_Handler({0x90f7860>, 0xc0006a78c0}, {0xa33b9a8, 0xc00239e0c0}, 0xc00239c240, 0xc00198b680)
    	/home/runner/go/pkg/mod/github.com/pulumi/pulumi/sdk/v3@v3.31.1/proto/go/provider.pb.go:2523 +0x138
    <http://google.golang.org/grpc.(*Server).processUnaryRPC(0xc001814540|google.golang.org/grpc.(*Server).processUnaryRPC(0xc001814540>, {0xa43f8c0, 0xc0006b0680}, 0xc00239a480, 0xc001e46750, 0x112b7a60, 0x0)
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.45.0/server.go:1282 +0xccf
    <http://google.golang.org/grpc.(*Server).handleStream(0xc001814540|google.golang.org/grpc.(*Server).handleStream(0xc001814540>, {0xa43f8c0, 0xc0006b0680}, 0xc00239a480, 0x0)
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.45.0/server.go:1619 +0xa2a
    <http://google.golang.org/grpc.(*Server).serveStreams.func1.2()|google.golang.org/grpc.(*Server).serveStreams.func1.2()>
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.45.0/server.go:921 +0x98
    created by <http://google.golang.org/grpc.(*Server).serveStreams.func1|google.golang.org/grpc.(*Server).serveStreams.func1>
    	/home/runner/go/pkg/mod/google.golang.org/grpc@v1.45.0/server.go:919 +0x294

    Error: invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF: Error: invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF
        at Object.callback (/snapshot/awsx/node_modules/@pulumi/pulumi/runtime/invoke.js:141:33)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client.ts:338:26)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client-interceptors.ts:426:34)
        at Object.onReceiveStatus (/snapshot/awsx/node_modules/@grpc/grpc-js/src/client-interceptors.ts:389:48)
        at /snapshot/awsx/node_modules/@grpc/grpc-js/src/call-stream.ts:276:24
        at processTicksAndRejections (node:internal/process/task_queues:78:11)

Outputs:
  + alias_arn: "arn:aws:kms:us-east-1:000000000000:alias/localstack-component-project-kms-alias-6e2d695"
  + key_arn  : "arn:aws:kms:us-east-1:000000000000:key/abe9dc2f-800a-4593-bb33-359d108a250a"

Resources:
    + 2 created
    7 unchanged
b
this is indeed part of the
Image
resource: https://github.com/pulumi/pulumi-awsx/blob/ec3ee6d18087f1ac94bde9c609aadbf3ae9e4792/awsx/ecr/image.ts#L70 I guess it’s possibly localstack doesn’t support
getCredentials
?
r
I'll look into localstack and report back...
Created an issue in localstack repo: https://github.com/localstack/localstack/issues/7186
@billowy-army-68599 I wonder if this is awsx specific? I mean, they must support standard ecr stuff. I'll look into that tmo.
b
i don’t think it’s awsx specific, the underlying call is just a standard pulumi
get
. You can double check by running it outside the component, do you get the same behaviour?
r
ecr.getCredentials
shows up 4 times in all of github: https://github.com/search?q=ecr.getCredentialsOutput&amp;type=code When you suggest
running it outside the component
, I'm not sure what that means.
b
aws.ecr.GetCredentials
is a pulumi specific call to retrieve credentials so it won’t show up elsewhere. When I say outside of the component, just make the call directly from your
__main__.py
Copy code
aws.ecr.get_credentials
instead of
Copy code
image = awsx.ecr.Image(
    resource_utils.get_name(awsx.ecr.Image),
    repository_url=repo.url,
    path=os.path.join(os.path.dirname(__file__), "..", "..", "docker", "_build"),
)
r
@billowy-army-68599 So running this
pulumilocal up
on this gives the same error:
Copy code
invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF
Code
Copy code
import pulumi_awsx as awsx
import pulumi_aws as aws
from utils import resource_utils

# create an ecr repository in aws
repo = awsx.ecr.Repository(
    resource_utils.get_name(awsx.ecr.Repository),
    tags=resource_utils.tags(),
)

gcr = aws.ecr.get_credentials(registry_id=repo.repository.id)
print(f"gcr=${gcr}")
Error
Copy code
Traceback (most recent call last):
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/./__main__.py", line 19, in <module>
        gcr = aws.ecr.get_credentials(registry_id=repo.repository.id)
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi_aws/ecr/get_credentials.py", line 91, in get_credentials
        __ret__ = pulumi.runtime.invoke('aws:ecr/getCredentials:getCredentials', __args__, opts=opts, typ=GetCredentialsResult).value
      File "/home/todd/tmp_5cuvoaql/backend-project-microservice/deploy/pulumi/venv/lib/python3.10/site-packages/pulumi/runtime/invoke.py", line 144, in invoke
        raise invoke_error
    Exception: invoke of aws:ecr/getCredentials:getCredentials failed: invocation of aws:ecr/getCredentials:getCredentials returned an error: error reading from server: EOF

    panic: runtime error: index out of range [0] with length 0
b
yeah, looks like localstack doesn’t support returning credentials from its ECR resource 😞
r
@billowy-army-68599 yeah, my quick perusal of the localstack code base make me wonder how this could work. The only related code I can find for
ecr
is here: https://github.com/localstack/localstack/blob/0221d2908307c2b00e91336aa07e608669341788/localstack/services/cloudformation/models/ecr.py#L14
Copy code
# TODO: might make sense to limit this only for resources with logical id "ContainerAssetsRepository"
class ECRRepository(GenericBaseModel):
    """
    This is a mock repository to support modern CDK bootstrapping templates.
    It is not intended to be used with other ECR resources.
    """
From this commit: https://github.com/localstack/localstack/commit/0221d2908307c2b00e91336aa07e608669341788 I think, for our use case,
localstack
is not going to work. Bummer, b/c that would have been really cool.