pulumi-awsx
pulumi-awsx copied to clipboard
Would like to use a different version of the pulumi-aws package then the one pinned by pulumi-awsx
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).
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.
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.
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.
@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
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
https://github.com/pulumi/pulumi-aws/compare/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);
}
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.
https://github.com/pulumi/pulumi-aws/issues/4004 relevant issue in pulumi-aws to track the root cause of being unable to use AWSX with newer settings for LocalStack.
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.