Not sure why but our setup has 1 ECR repo for all ...
# aws
f
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
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
sort of. if im in one stack i would want to get awsx.ecr.Repository by loading it via name or urn.
m
Maybe you want to use .get() or outputs and StackReferences