https://pulumi.com logo
Title
p

polite-umbrella-11196

02/27/2023, 8:27 PM
For that matter, https://www.pulumi.com/docs/guides/crosswalk/aws/elb/ refers to both createListener and createTargetGroup which doesn’t seem to be on the target/alb objects?
l

little-cartoon-10569

02/27/2023, 8:31 PM
Crosswalk is changing a lot. Are you interested in 0.40.1 or 1.0.0-beta?
p

polite-umbrella-11196

02/27/2023, 8:31 PM
lol
Brand new project
And also brand new pulumi user
My package.json is set to ^1.0.0
so I guess the latter?
l

little-cartoon-10569

02/27/2023, 8:32 PM
Ah. Well, 0.40.1 is still recommended in many cases. I'll see what I can find for 1.0.0.
In general, rich classes and methods like that don't get published to the API docs, you've got to use your IDE to find the docs.
p

polite-umbrella-11196

02/27/2023, 8:33 PM
😐
l

little-cartoon-10569

02/27/2023, 8:33 PM
Same problem for mixins.
p

polite-umbrella-11196

02/27/2023, 8:33 PM
My IDE is vim
and however it’s installed, ALE isn’t finding the types.
l

little-cartoon-10569

02/27/2023, 8:34 PM
I've got VSCode, it has no problems with this stuff, I'll see what I can see.
p

polite-umbrella-11196

02/27/2023, 8:34 PM
Oh yeah, no doubt this is all self-inflicted, except for the 1.0.0 vs 0.4.1 confusion and the main page for awsx not being updated to what will be installed by default 😄
l

little-cartoon-10569

02/27/2023, 8:36 PM
Confirmed that createTargetGroup is not in 1.0.2. It's 0.40.1 only.
p

polite-umbrella-11196

02/27/2023, 8:36 PM
(Needed to install
typescript
as a devDependency so now at least I get links into definitions)
Cool, cool. How should I create a targetGroup, listener in v1?
(This is the recipe I’m following, fwiw)
l

little-cartoon-10569

02/27/2023, 8:39 PM
They're separate resources. Create them using
new
.
p

polite-umbrella-11196

02/27/2023, 8:40 PM
it looks like maybe I should be adding them to the alb
listeners
parameters instead of creating them as a separate action?
cause I”m not seeing a listener object…
l

little-cartoon-10569

02/27/2023, 8:40 PM
Use the
@pulumi/aws
resources. For example, in TargetGroupAttachment, a target group is defined thus:
targetGroup?: pulumi.Input<<http://pulumiAws.lb|pulumiAws.lb>.TargetGroup>;
Listener is also in
@pulumi/aws
p

polite-umbrella-11196

02/27/2023, 8:43 PM
const alb = new awsx.lb.ApplicationLoadBalancer('recorder-traffic', {
  listeners: [
    {
      port: 80,
      protocol: 'HTTP',
      defaultActions: [{
        type: 'redirect',
        redirect: {
          protocol: 'HTTPS',
          port: '443',
          statusCode: 'HTTP_301',
        },
      }],
    },
  ],
});
Yeah this looks like the path I found too
Does that look right?
l

little-cartoon-10569

02/27/2023, 8:44 PM
Looks right, but I've never used AWSX. I find the AWS library to be just as convenient, and it creates fewer resources and has fewer bits of logic for me to get lost in.
p

polite-umbrella-11196

02/27/2023, 8:44 PM
Yeah, fair.
I guess this is part of the awsx challenge - if I create the listeners inline, how do I pass them in to route53 to create a new domain pointing at them?
I want to do
alb.listeners[1].endpoint
but it’s an
Output<>
type which means I need to hit it with some kind of uglystick?
l

little-cartoon-10569

02/27/2023, 8:54 PM
Probably not. Outputs can be passed to constructors of other Pulumi resources.
If you want to use them in console logging, or building scripts on the fly (maybe for configuring environments that you're building at the same time), then yes, you need to
apply()
to get those values.
p

polite-umbrella-11196

02/27/2023, 8:55 PM
If it’s Output<Listener[]> and I want to refer to the second listener…?
const albDomain = new aws.route53.Record(domainName, {
  name: domainName,
  zoneId: hostedZoneId,
  type: 'CNAME',
  records: [alb.listeners[1].endpoint],
  ttl: 600,
});
l

little-cartoon-10569

02/27/2023, 8:56 PM
You might be able to do that? Pulumi has some smart lifting code. If not, you can use
listeners.apply((listeners) => listeners[1]).endpoint
p

polite-umbrella-11196

02/27/2023, 8:57 PM
huh, endpoint doesn’t actually exist on a listener….
Getting tripped up by 0.4.2 semantics again.
Do you have a pure
aws
example that covers that material instead?
l

little-cartoon-10569

02/27/2023, 9:49 PM
I'll have a look
I can't see anything better than the API docs. The usual pattern is: • Create the load balancer. • Create the target group(s). • Create the listeners (using loadBalander.arn, and targetGroup.arn in the default action's target group). • Create listener rules if needed (with listener.arn and targetGroup.arn).
p

polite-umbrella-11196

02/27/2023, 10:00 PM
Yeah; I’m just liable to forget something I need, so having a useful recipe to copy-pasta from is always helpful.
l

little-cartoon-10569

02/27/2023, 10:01 PM
The ListenerRule API docs have most of the elements. Only the target groups are missing.
p

polite-umbrella-11196

02/27/2023, 10:01 PM
I’ll give it a go. Thanks for the assistance 🙂
const task = new aws.ecs.TaskDefinition('recorder-task', {
    family: 'service',
    containerDefinitions: JSON.stringify([
      {
        name: 'recorder',
        image: imageUri,
        cpu: 512,
        memory: 128,
        portMappings: [{ containerPort: 80, hostPort: 80 }],
      },
    ]),
  });
This generates an error that
Container.image repository should be 255 characters or less.
. Any suggestions on what to try?
Creating one manually on the AWS CLI seems to use that url in the image field…
l

little-cartoon-10569

02/27/2023, 11:32 PM
I don't see where repository is defined. However there is a bug there. You're stringifying an Output. That will call .toString() on the Output, which is never right.
p

polite-umbrella-11196

02/27/2023, 11:32 PM
Yuuuuup
l

little-cartoon-10569

02/27/2023, 11:33 PM
If you need to stringify, do it inside an apply, so it is wrapped in an Output