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

Pulumi.DockerBuild.Image fail to preview when trying to create ECR repo and image same time #251

Open
guitarrapc opened this issue Sep 10, 2024 · 0 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@guitarrapc
Copy link

guitarrapc commented Sep 10, 2024

What happened?

Pulumi.DockerBuild.Image shows an error on pulumi preview when the ECR repository has not yet been created, but it does create the repository at the same time the docker build is performed. However, pulumi preview succeeds if the ECR repository already exists. Since Pulumi.Docker.Image can preview even when the ECR and Docker are created at the same time, is this by design, or am I missing something?

Error meesage.

  docker-build:index:Image (dummy-image):
    error: docker-build:index:Image resource 'dummy-image': property exports[0] value {<nil>} has a problem: at least one tag or export name is needed when pushing to a registry

Example

pulumi preview failure sample.

var ecr = new Pulumi.Aws.Ecr.Repository($"dummy-repo", new()
{
    ForceDelete = true,
});
var authToken = Pulumi.Aws.Ecr.GetAuthorizationToken.Invoke(new()
{
    RegistryId = ecr.RegistryId,
});
var image = new Pulumi.DockerBuild.Image($"dummy-image", new()
{
    Dockerfile = new Pulumi.DockerBuild.Inputs.DockerfileArgs
    {
        Inline = """
        FROM envoy
        """,
    },
    Platforms = [Pulumi.DockerBuild.Platform.Linux_amd64, Pulumi.DockerBuild.Platform.Linux_arm64],
    Push = true,
    Registries = [
        new Pulumi.DockerBuild.Inputs.RegistryArgs
        {
            Address = ecr.RepositoryUrl,
            Username = authToken.Apply(x => x.UserName),
            Password = authToken.Apply(x => x.Password)
        }
    ],
    Tags = [ ecr.RepositoryUrl.Apply(x => $"{x}:latest"), ], // `pulumi preview` fail
});

pulumi preview success sample, just changed Tags not use Pulumi.Ouput.Apply and change to literal.

var image = new Pulumi.DockerBuild.Image($"dummy-image", new()
{
    Dockerfile = new Pulumi.DockerBuild.Inputs.DockerfileArgs
    {
        Inline = """
        FROM envoy
        """,
    },
    Platforms = [Pulumi.DockerBuild.Platform.Linux_amd64, Pulumi.DockerBuild.Platform.Linux_arm64],
    Push = true,
    Registries = [
        new Pulumi.DockerBuild.Inputs.RegistryArgs
        {
            Address = ecr.RepositoryUrl,
            Username = authToken.Apply(x => x.UserName),
            Password = authToken.Apply(x => x.Password)
        }
    ],
    Tags = ["0123456789012.dkr.ecr.ap-northeast-1.amazonaws.com/dummy-repo-abcdef:latest"], // change to literal
});

Output of pulumi about

CLI
Version      3.131.0
Go Version   go1.23.0
Go Compiler  gc

Plugins
KIND      NAME          VERSION
resource  aws           6.51.0
resource  aws-native    0.119.0
resource  azure-native  2.57.0
resource  docker-build  0.0.6
language  dotnet        unknown

Host
OS       Microsoft Windows 11 Pro
Version  10.0.22631 Build 22631
Arch     x86_64

This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='8.0.400'

Dependencies:
NAME                VERSION
Pulumi              3.66.2
Pulumi.Aws          6.51.0
Pulumi.AwsNative    0.119.0
Pulumi.DockerBuild  0.0.6

Additional context

Example code is logically same as official api-docs https://www.pulumi.com/registry/packages/docker-build/api-docs/image/ do.

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@guitarrapc guitarrapc added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 10, 2024
@blampe blampe removed the needs-triage Needs attention from the triage team label Sep 12, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants