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

Would like to use a different version of the pulumi-aws package then the one pinned by pulumi-awsx #1191

Closed
lakkeger opened this issue Jan 3, 2024 · 8 comments · Fixed by #1295
Assignees
Labels
kind/enhancement Improvements or new features resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Milestone

Comments

@lakkeger
Copy link

lakkeger commented Jan 3, 2024

What happened?

Current implementation ignores installed package version and falls back to some hardcoded pulumi-aws version.

Example

Given the below sample project:

import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx

lb = awsx.lb.ApplicationLoadBalancer("lb")
cluster = aws.ecs.Cluster("cluster")

service = awsx.ecs.FargateService("service",
    cluster=cluster.arn,
    assign_public_ip=True,
    desired_count=2,
    task_definition_args=awsx.ecs.FargateServiceTaskDefinitionArgs(
        container=awsx.ecs.TaskDefinitionContainerDefinitionArgs(
            name="my-service",
            image="nginx:latest",
            cpu=128,
            memory=512,
            essential=True,
            port_mappings=[awsx.ecs.TaskDefinitionPortMappingArgs(
                container_port=80,
                target_group=lb.default_target_group,
            )],
        ),
    ))

pulumi.export("url", pulumi.Output.concat("http://", lb.load_balancer.dns_name))

I ran preview:

$ pulumilocal preview
Updating this Stack with LocalStack config
Previewing update (dev):
     Type                                Name            Plan       Info
 +   pulumi:pulumi:Stack                 ecs-sample-dev  create     1 error
 +   ├─ awsx:lb:ApplicationLoadBalancer  lb              create
 +   ├─ aws:ecs:Cluster                  cluster         create
     └─ pulumi:providers:aws             default_6_9_0              1 error

Diagnostics:
  pulumi:providers:aws (default_6_9_0):
    error: pulumi:providers:aws resource 'default_6_9_0' has a problem: could not validate provider configuration: Invalid or unknown key. Check `pulumi config get aws:endpoints`.

  pulumi:pulumi:Stack (ecs-sample-dev):
    error: Resource monitor has terminated, shutting down

Output of pulumi about

CLI
Version      3.99.0
Go Version   go1.21.5
Go Compiler  gc

Plugins
NAME    VERSION
aws     6.17.0
awsx    2.4.0
docker  4.5.0
local   1.2.1
python  unknown

Host
OS       darwin
Version  14.2.1
Arch     arm64

This project is written in python: executable='/Users/lakkeger/Workspace/pulumi/ecs-sample/venv/bin/python3' version='3.11.5'

Backend
Name           lakkeger-MacBook-Pro.local
URL            file:///Users/lakkeger/Workspace/pulumi/ecs-sample
User           lakkeger
Organizations
Token type     personal

Dependencies:
NAME          VERSION
pip           23.3.2
pulumi-awsx   2.4.0
pulumi-local  1.2.1
setuptools    69.0.3
wheel         0.42.0

Pulumi locates its logs in /var/folders/8x/dyq5jnvj7md_z7km73gn496m0000gn/T/ by default
warning: Failed to get information about the current stack: No current snapshot

Additional context

pulumi-local is a thin wrapper for local development on Localstack.
Another issue will be raised regarding the endpoints in the pulumi-aws repo.

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).

@lakkeger lakkeger added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 3, 2024
@mjeffryes
Copy link
Contributor

Yes, that's a limitation of the current design I believe. We explicitly pin the underlying provider version here: https://github.com/pulumi/pulumi-awsx/blob/master/awsx/package.json#L23C6-L23C6

I can understand the desire to use an alternate version, but there would potentially be some compatibility complications to address.

@mjeffryes mjeffryes changed the title pulumi-awsx doesn't rely on the installed pulumi-aws package version Would like to use a different version of the pulumi-aws package then the one pinned by pulumi-awsx Jan 3, 2024
@mjeffryes mjeffryes added kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jan 3, 2024
@lakkeger
Copy link
Author

lakkeger commented Jan 4, 2024

Hi @mjeffryes,
Thanks for clarifying and it would be a nice touch to add the option to change the version.
As a further enhancement could you please add the used dependencies and their version constraints to the docs? As I believe most users' assumption would be that the package uses the locally available packages.

Additionally the aws package until v6.12.0 renders this package unusable to anyone who wish to use the endpoints option.

@mikeshultz
Copy link

Also just ran into this issue. Took a while to narrow it down here.

@lakkeger thanks for reporting it. Did you find any way to work around this other than not using pulumi-awsx? I skipped configuring aws:endpoints config and instead configured my AWS profile with endpoint_url but it seems that's getting ignored as well.

@lakkeger
Copy link
Author

lakkeger commented Apr 15, 2024

@mikeshultz Unfortunately no. By being selective with my aws endpoints I could reduce the run time to a reasonable length:
https://github.com/lakkeger/localstack-sample-pulumi-eks/blob/main/Pulumi.test.yaml

@t0yv0 t0yv0 added the size/S Estimated effort to complete (1-2 days). label May 24, 2024
@t0yv0
Copy link
Member

t0yv0 commented May 30, 2024

I have some updates on this issue. There are actually two issues: one is being unable to use pulumilocal helper that sets aws:endpoints - the issue persists and still reproduces on awsx 2.10.0 and aws 6.32.0.

    error: pulumi:providers:aws resource 'default_6_32_0' has a problem: `aws:endpoints` is not a valid configuration key for the aws provider. If the referenced key is not intended for the provider, please choose a different namespace from `aws:`.

This is an issue with the pulumi-aws provider. I was able to bisect it and see that it is fixed in v6.36.0.

6.34.0 BAD
6.35.0 BAD
6.36.0 OK

pulumi/pulumi-aws@v6.35.0...v6.36.0

Looking at the diff, it seems that in v6.36.0 endpoints structure received an update to recognize workspacesweb:

    /**
     * @return Use this to override the default service endpoint URL
     *
     */
    public Optional<String> workspacesweb() {
        return Optional.ofNullable(this.workspacesweb);
    }

@t0yv0
Copy link
Member

t0yv0 commented May 30, 2024

The good news is that we should be able to release an awsx update shortly that is built against the latest AWS provider and is able to recognize aws:endpoints.

This solution will break again when pulumilocal adds more entries to aws:endpoints and pulumi-aws provider will be lagging behind. There is an issue here I will extract for the pulumi-aws provider to handle this gracefully (both lax parsing and better error reporting).

On the issue as stated, we will have to keep that open; the ability to substitute the underlying provider, currently I am testing transforms workaround but it is not succeeding in fully substitue all the versions of pulumi-aws:

import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx
from pulumi.runtime import x_register_stack_transform

def aws_provider_version_transform(args: pulumi.ResourceTransformArgs):
    if args.type_.startswith("aws:"):
        print("Transformed ", args.type_)
        return pulumi.ResourceTransformResult(
            props=args.props,
            opts=pulumi.ResourceOptions.merge(args.opts, pulumi.ResourceOptions(
                version="6.36.0",
            ))
        )

x_register_stack_transform(aws_provider_version_transform)

If we cannot make that work perhaps another solution can provide the desired capability.

@t0yv0 t0yv0 self-assigned this May 30, 2024
@t0yv0
Copy link
Member

t0yv0 commented May 30, 2024

pulumi/pulumi-aws#4004 relevant issue in pulumi-aws to track the root cause of being unable to use AWSX with newer settings for LocalStack.

@t0yv0
Copy link
Member

t0yv0 commented May 30, 2024

Digging a little bit further and getting some help from @justinvp from the core team, there is now a supported way to use a different version of pulumi-aws package with your program. Example:

import pulumi
import pulumi_aws as aws
import pulumi_awsx as awsx

awsp = aws.Provider("awsp", opts=pulumi.ResourceOptions(version="6.36.0"))
lb = awsx.lb.ApplicationLoadBalancer("lb", opts=pulumi.ResourceOptions(providers={"aws": awsp}))

When I run this program, only the desired version of the provider ("6.36.0" in this example) will be used, even if the version of awsx is built against a different aws version ("6.37.1" in my case).

Note that Pulumi currently still may install 6.37.1 version into the plugin cache (pulumi plugin ls), but it will not use it for this program. This can be verified by:

PULUMI_DEBUG_GRPC="$PWD/preview.json" pulumi preview

This also serves as a workaround for the localstack issue - specifying 6.36.0 or higher in this way gets past the problem.

t0yv0 added a commit that referenced this issue May 30, 2024
Documents how AWS provider version is selected and gives an example of overriding it.

Fixes #1191
@t0yv0 t0yv0 added this to the 0.105 milestone May 30, 2024
t0yv0 added a commit that referenced this issue May 30, 2024
Documents how AWS provider version is selected and gives an example of
overriding it.

Fixes #1191
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label May 30, 2024
t0yv0 added a commit that referenced this issue May 30, 2024
Dependency updates:

```
@pulumi/aws: 6.32.0 to 6.37.1
@pulumi/sdk: v3.112.0 to v3.116.1
```

In particular AWS v6.36.0 has a change that makes it work better with
LocalStack as it no longer fails opaquely when given an workspacesweb
endpoint override in `aws:endpoints`.

This does not solve #1191
yet but alleviates most of the underlying trouble.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features resolution/fixed This issue was fixed size/S Estimated effort to complete (1-2 days).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants