This message was deleted.
s
This message was deleted.
b
Hi @white-rainbow-68240 Good to hear you are trialling Pulumi - sorry to hear you hit an issue around the default VPC
These examples are just to show people what it's capable of - if you show me the code you are using for the FargateService, then I can and help you hook in your own VPC
w
Ah, I'm on my phone right now. I just used a couple of examples from the docs and pointed to my own image. Just to clarify, I do not have a default vpc due to how the AWS team did things. I need to know how I can create one from scratch. Is there any minimal fargate service example with a vpc created via Pulumi?
I will try to share some code in a few hours 👍
b
can you link me to the docs page you are using?
w
Copy code
import * as awsx from "@pulumi/awsx";

// const vpc = new awsx.ec2.Vpc("frea-api", {
//   cidrBlock: "10.0.0.0/16",
// });

const cluster = new awsx.ecs.Cluster("cluster");

// let lb = new awsx.lb.NetworkListener("frea-api", { port: 80,  });

const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
  "frea-api-lb",
  { external: true, securityGroups: cluster.securityGroups }
);
const web = alb.createListener("web", { port: 80, external: true });

let service = new awsx.ecs.FargateService("frea-api-svc", {
  cluster,
  desiredCount: 2,
  taskDefinitionArgs: {
    container: {
      image: awsx.ecs.Image.fromPath("frea-api-image", "../server"),
      memory: 512,
      portMappings: [web],
    },
  },
});

export const url = web.endpoint.hostname;
b
ok, leave it with me a little bit 🙂
👍 1
w
That's my last try.
I tried to insert the vpc that I commented out in a bunch of places, but no luck.
Thanks @broad-dog-22463
b
did you try this?
Copy code
import * as awsx from "@pulumi/awsx";

const vpc = new awsx.ec2.Vpc("frea-api", {
  cidrBlock: "10.0.0.0/16",
});

const cluster = new awsx.ecs.Cluster("cluster", {
    vpc: vpc,
});
// let lb = new awsx.lb.NetworkListener("frea-api", { port: 80,  });
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
    "frea-api-lb",
    {
        external: true,
        securityGroups: cluster.securityGroups,
        vpc: vpc,
    }
);
const web = alb.createListener("web", { port: 80, external: true, vpc: vpc });
let service = new awsx.ecs.FargateService("frea-api-svc", {
    cluster,
    desiredCount: 2,
    subnets: vpc.privateSubnetIds,
    taskDefinitionArgs: {
        container: {
            image: awsx.ecs.Image.fromPath("frea-api-image", "../server"),
            memory: 512,
            portMappings: [web],
        },
    },
});
export const url = web.endpoint.hostname;
where vpc is being set on everyting and then subnets are set from the vpc?
w
Running it now, and I got past the error. Waiting for the deploy to finish...
Hey, @broad-dog-22463. Check this out: This is my first Fargate service running my node.js API. This is all thanks to your help ❤️
b
ah fantastic 🙂 Glad it worked for you!!
Sorry you hit that first glitch
w
No probs. I'm just glad I got a quick response.
b
Let us know if you need anything else
👍 1