For that matter, <https://www.pulumi.com/docs/guid...
# typescript
p
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
Crosswalk is changing a lot. Are you interested in 0.40.1 or 1.0.0-beta?
p
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
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
😐
l
Same problem for mixins.
p
My IDE is vim
and however it’s installed, ALE isn’t finding the types.
l
I've got VSCode, it has no problems with this stuff, I'll see what I can see.
p
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
Confirmed that createTargetGroup is not in 1.0.2. It's 0.40.1 only.
p
(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
They're separate resources. Create them using
new
.
p
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
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
Copy code
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
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
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
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
If it’s Output<Listener[]> and I want to refer to the second listener…?
Copy code
const albDomain = new aws.route53.Record(domainName, {
  name: domainName,
  zoneId: hostedZoneId,
  type: 'CNAME',
  records: [alb.listeners[1].endpoint],
  ttl: 600,
});
l
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
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
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
Yeah; I’m just liable to forget something I need, so having a useful recipe to copy-pasta from is always helpful.
l
The ListenerRule API docs have most of the elements. Only the target groups are missing.
p
I’ll give it a go. Thanks for the assistance 🙂
Copy code
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
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
Yuuuuup
l
If you need to stringify, do it inside an apply, so it is wrapped in an Output