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

Non-unique component names when using awsx.ecs.FargateTaskDefinition #250

Open
fredrikahs opened this issue Apr 16, 2024 · 2 comments · May be fixed by #299
Open

Non-unique component names when using awsx.ecs.FargateTaskDefinition #250

fredrikahs opened this issue Apr 16, 2024 · 2 comments · May be fixed by #299
Assignees

Comments

@fredrikahs
Copy link

When creating an awsx.ecs.FargateTaskDefinition I get the following issue:

|  Creating    MyTaskDefinition awsx:ecs:FargateTaskDefinition → MyTaskDefinition aws:ecs:TaskDefinition
|  Created     MyTaskDefinition awsx:ecs:FargateTaskDefinition → MyTaskDefinition aws:ecs:TaskDefinition
|  Error        Invalid component name "MyTaskDefinition". Component names must be unique.
⠼  Finalizing...time=2024-04-16T13:31:16.747Z level=INFO msg="done running stack command"
time=2024-04-16T13:31:16.747Z level=INFO msg="stack command complete"
⠇  Finalizing...time=2024-04-16T13:31:17.143Z level=INFO msg="INFO putting links app=sst-infrastructure stage=dev"

×  Failed
   Invalid component name "MyTaskDefinition". Component names must be unique.

I'm guessing this has to do with the awsx package creating it's own internal components with the same name? See https://github.com/pulumi/pulumi-awsx/blob/master/awsx-classic/ecs/taskDefinition.ts#L81

Is there any way to get around this?

@vnawrath
Copy link

I have the same issue with awsx.lb.ApplicationLoadBalancer.
Here's my sst.config.ts:

/// <reference path="./.sst/platform/config.d.ts" />
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

export default $config({
  app(input) {
    return {
      name: "sliders-remix",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
    };
  },
  async run() {
    // Create an ECS cluster to run a container-based service.
    const cluster = new aws.ecs.Cluster("SlidersStrapiCluster");

    // An ALB to serve the container endpoint to the internet
    const loadbalancer = new awsx.lb.ApplicationLoadBalancer(
      "SlidersStrapiLB",
      {}
    );

    // An ECR repository to store our application's container image
    const repo = new awsx.ecr.Repository("SlidersStrapiRepo", {
      forceDelete: true,
    });

    // Build and publish our application's container image from ./app to the ECR repository
    const image = new awsx.ecr.Image("SlidersStrapiImage", {
      repositoryUrl: repo.url,
      dockerfile: "./apps/strapi/Dockerfile",
      platform: "linux/amd64",
    });

    // Deploy an ECS Service on Fargate to host the application container
    const service = new awsx.ecs.FargateService("SlidersStrapiService", {
      cluster: cluster.arn,
      assignPublicIp: true,
      taskDefinitionArgs: {
        container: {
          name: "app",
          image: image.imageUri,
          cpu: 512,
          memory: 128,
          essential: true,
          portMappings: [
            {
              containerPort: 80,
              targetGroup: loadbalancer.defaultTargetGroup,
            },
          ],
        },
      },
    });

    new sst.aws.Remix("RemixWeb", {
      path: "apps/remix-web/",
    });
  },
});

And here is the error output:

...
|  Creating    SlidersStrapiRepo awsx:ecr:Repository
|  Creating    SlidersStrapiRepo awsx:ecr:Repository → slidersstrapirepo aws:ecr:Repository
|  Error        Invalid component name "SlidersStrapiLB". Component names must be unique.
|  Created     SlidersStrapiRepo awsx:ecr:Repository → slidersstrapirepo aws:ecr:Repository (1.5s)
|  Creating    SlidersStrapiRepo awsx:ecr:Repository → slidersstrapirepo aws:ecr:LifecyclePolicy
|  Created     SlidersStrapiRepo awsx:ecr:Repository → slidersstrapirepo aws:ecr:LifecyclePolicy
|  Created     SlidersStrapiRepo awsx:ecr:Repository (2.0s)
|  Error        Invalid component name "slidersstrapirepo". Component names must start with an uppercase letter and contain only alphanumeric characters.
|  Created     RemixWeb sst:aws:Remix → RemixWebCdnWaiter sst:aws:DistributionDeploymentWaiter (199.6s)

×  Failed
   Invalid component name "SlidersStrapiLB". Component names must be unique.
   Invalid component name "slidersstrapirepo". Component names must start with an uppercase letter and contain only alphanumeric characters.

I'm quite new to this, so any help would be very appreciated. Let me know if I can provide additional info.

@devakrishna33
Copy link

devakrishna33 commented Apr 24, 2024

if (args.type.startsWith("pulumi")) {

I have logged the args here it's coming as

{
    resource: LifecyclePolicy {
      __pulumiResource: true,
      __pulumiType: 'aws:ecr/lifecyclePolicy:LifecyclePolicy',
      __transformations: [Array]
    },
    type: 'aws:ecr/lifecyclePolicy:LifecyclePolicy',
    name: 'populatefensworkerrepository',
    props: { policy: undefined, repository: undefined, registryId: undefined },
    opts: {
      version: '6.32.0',
      urn: 'urn:pulumi:dev::misc::awsx:ecr:Repository$aws:ecr/lifecyclePolicy:LifecyclePolicy::populatefensworkerrepository'
    }
 }

since type is not starting with pulumi it's not ignored, instead we can have a condition like

if (args.opts.urn?.startsWith("urn:pulumi")) {
  return;
}

this seems to fix the problem for now

devakrishna33 added a commit to devakrishna33/ion that referenced this issue Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants