fast-island-38778
09/02/2022, 9:54 PM"dependencies": {
"@pulumi/aws": "^5.13.0",
"@pulumi/awsx": "^0.40.0",
"@pulumi/pulumi": "^3.39.1"
}
i also have attached an example error i was gettingclever-sunset-76585
09/02/2022, 10:06 PMconst image = new awsx.ecr.RepositoryImage("image", {
repositoryUrl: repo.repository.repositoryUrl,
...
});
Also when you get a chance, can you please open an issue here: https://github.com/pulumi/pulumi-hugo/issues/new/choose?fast-island-38778
09/02/2022, 10:09 PMawsx.ecr.Image
allows you to specify the docker file to build from, e.g. it’s doing a build and publish actionclever-sunset-76585
09/02/2022, 10:09 PMRepositoryImage
isn't going to work. It's not the right thing.fast-island-38778
09/02/2022, 10:09 PMawsx.ecr.RepositoryImage
only lets you specify the image name, e.g. it only takes in a stringclever-sunset-76585
09/02/2022, 10:15 PMRepository
component resource from awsx
also has a buildAndPushImage
method. So maybe:
repo.buildAndPushImage({context: "./app", dockerfile: "./app/Dockerfile-multistage", cacheFrom: {stages: ["build"]}})
This will build the image and push to the repository that you are executing the buildAndPushImage
method against.fast-island-38778
09/02/2022, 10:21 PMclever-sunset-76585
09/02/2022, 10:23 PMbutYeah I was wrong to ask you to useonly lets you specify the image name, e.g. it only takes in a stringawsx.ecr.RepositoryImage
awsx.ecr.RepositoryImage
initially. I didn't pay close attention to its constructor. The `Repository`'s buildAndPushImage
is what you are likely looking for. You can even pass the result of that method to any image
property that requires the ID of an image that exists in ECR.fast-island-38778
09/02/2022, 10:25 PMpulumi/awsx
and pulumi/aws
clever-sunset-76585
09/02/2022, 10:31 PMpulumi/aws
is a provider package vs. pulumi/awsx
is a package that has hand-authored component resources. Think of awsx
as a helpful wrapper library that does a lot behind-the-scenes for you. Some people prefer that, others want more control and so they build wrapper components themselves using pulumi/aws
directly.
As a side note, there are also Pulumi-native providers. But if you are new to Pulumi, my suggestion is to stick with pulumi/aws
for now. But know that there is also a pulumi/aws-native
whose goal is to offer everything that pulumi/aws
has. It differs in its internals of how each of those packages are generated.fast-island-38778
09/02/2022, 10:34 PMimport * as awsx from "@pulumi/awsx";
import * as aws from "@pulumi/aws";
// Create a repository.
const repo = new awsx.ecr.Repository("my-repo");
const image = repo.buildAndPushImage({
context: ".",
dockerfile: "./Dockerfile",
cacheFrom: { stages: ["build"] },
});
// Create an ECS Cluster
const cluster = new awsx.ecs.Cluster("default-cluster");
// // Create a load balancer on port 80 and spin up two instances of Nginx.
const lb = new awsx.lb.ApplicationLoadBalancer("nginx-lb");
const service = new awsx.ecs.FargateService("my-service", {
cluster: cluster,
taskDefinitionArgs: {
container: {
image: image,
cpu: 512,
memory: 128,
essential: true,
portMappings: [
{
containerPort: 80,
},
],
},
},
});
// Export the load balancer's address so that it's easy to access.
export const url = lb.loadBalancer.dnsName;
clever-sunset-76585
09/02/2022, 10:48 PM