https://pulumi.com logo
#aws
Title
# aws
f

fast-river-57630

01/07/2022, 7:16 PM
Not sure why but our setup has 1 ECR repo for all 3 stacks. I'm adding some new FargateServices and using
awsx.ecs.Image.fromPath
. seems like it demands an ECR repo per stack? I cant pass
awsx.ecs.Image.fromPath(name-of-existing-ecr-repo)
into it?
this is a new ecr repo for this image but the fargate service will be deployed in different stacks/vpcs so I'm trying to figure out if I need this new one to have 1 per stack or just the 1
m

millions-furniture-75402

01/07/2022, 10:06 PM
Maybe this example will give you something to work with.
Copy code
const containerRepository = new awsx.ecr.Repository(`${appName}-image`, {
  lifeCyclePolicyArgs: {
    rules: [
      {
        selection: "untagged",
        maximumNumberOfImages: 5,
      },
    ],
  },
  repository: new aws.ecr.Repository(`${appName}-image`, {
    imageScanningConfiguration: {
      scanOnPush: true,
    },
    imageTagMutability: "MUTABLE",
  }),
});

const applicationImage = containerRepository.buildAndPushImage({
  args: {
    NODE_AUTH_TOKEN: nodeAuthToken,
  },
  env: {
    DOCKER_BUILDKIT: "1",
  },
});

const cluster = new awsx.ecs.Cluster(`${appName}-cluster`, {
  securityGroups: [],
  vpc: vpc,
});

new awsx.ecs.FargateService(`${appName}-service`, {
  assignPublicIp: false,
  cluster,
  deploymentMinimumHealthyPercent: 100,
  deploymentMaximumPercent: 200,
  desiredCount: 1,
  healthCheckGracePeriodSeconds: 5,
  securityGroups: [appSecurityGroup],
  subnets: privateSubnetIds,
  taskDefinitionArgs: {
    logGroup: new aws.cloudwatch.LogGroup(`${appName}-service-lg`, {
      name: `/aws/ecs/${appName}-service`,
      retentionInDays: 14,
    }),
    containers: {
      [`${appName}-service`]: {
        image: applicationImage,
        environment: [
          { name: "PORT", value: "443" },
        ],
      },
    },
    executionRole,
    taskRole: applicationRole,
  },
});
f

fast-river-57630

01/07/2022, 10:10 PM
sort of. if im in one stack i would want to get awsx.ecr.Repository by loading it via name or urn.
m

millions-furniture-75402

01/10/2022, 1:57 PM
Maybe you want to use .get() or outputs and StackReferences