This message was deleted.
s
This message was deleted.
b
This is what I see in vscode when I go to the definition (/home/charlie/workspace/mxd/infra/service/node_modules/@pulumi/awsx/ecs/fargateService.d.ts):
Copy code
export interface FargateServiceArgs {
    // ...
    cluster?: ecs.Cluster;
    // ... 
  
}
But when I look at the source the docs link to I see: (https://github.com/pulumi/pulumi-awsx/blob/master/awsx/schema-types.ts)
Copy code
export interface FargateServiceArgs {
    readonly cluster?: pulumi.Input<string>;
    // ...
}
Am I crazy?
b
what version of awsx are you using?
b
I wrote above. the one I was originally using
0.40.1
But I just updated to the one linked by the docs page (
v1.0.0-beta.7
) and it's still the same issue
The type is defined here: /home/charlie/workspace/mxd/infra/service/node_modules/@pulumi/awsx/ecs/fargateService.d.ts
This contradicts the documentation
which says cluster is:
Copy code
ARN of an ECS cluster.
This is causing me issues because It's not clear how to leverage the output of another stack in building a new FargateService object
If it were just the
ARN of an ECS cluster
then I could use the string output... unfortunately it is looking for an awsx.ecs.Cluster object as a property on the args parameter
Anyone have advice on how to resolve?
@millions-furniture-75402? This is me trying to fix the issue I had before
m
Sorry, what issue?
b
@millions-furniture-75402 so I'm trying to use stack reference and build each microservice in their own stack... instead of in one single stack (what we talked about originally)
m
Ahh okay, yeah.
b
Originally I was creating a bunch of microservices by looping through a list of services in a single stack index.ts... This presented its own issues like incremental build/deploy, I wanted a noop basically for micro-services that hadn't changed
so now I'm trying to build a Base infrastructure pulumi stack/script
which creates an ALB
and listener
and then have a seperate Pulumi stack for each microservice that attaches to the ALB
m
right
b
by creating an ecs FargateService attached to a TargetGroup and use a stack reference to attach that to the ALB in the base infr
... so the issue I'm having is that the FargateService requires a awsx.ecs.Cluster type object as part of it's FargateServiceArgs or whatever
and that is not a primitive value which can be provided by the output of the base stack
e.g. If it was just using an arn as input then that would be simple enough to grab from the output of the base stack
but since it's expecting an object of interface awsx.ecs.Cluster with all the fields/methods required I'm not sure what to do
m
Do you have something like?
Copy code
const cluster = new awsx.ecs.Cluster(`${appName}-cluster`, {
  securityGroups: [],
  vpc,
});
b
yup in the base stack
m
Your Stack Reference is an ARN or ID and now you have an issue because you need the awsx object again?
b
yes exactly
m
You need to use a
.get()
b
I'm outputting a string
but the constructor requires an awsx.ecs.Cluster object
m
Right, the getters help you recreate an object from an ID
b
@millions-furniture-75402 is there any documentation on how to use
.get
?
m
ugh... but maybe that's not exposed in awsx
b
I was looking for ways to get the resource object solely using it's ARN
or id
but couldn't find a way
m
Here is an example of doing a similar thing with a security group
Copy code
const mySg = awsx.ec2.SecurityGroup.fromExistingId(
      "my-sg",
      mySgId,
      { vpc },
    );
the normal packages have getters, but I don't think awsx necessarily does, it might have helper methods like above instead
Unfortunately, my similar use was using EC2 Instances, instead of fargate. I believe all my clusters are running single services.
b
hmmm the awsx.ecs.Cluster class doesn't even appear in the documentation for some reason
and the awsx.ecs.FargateService docs seem to not align with the actual definition
m
Use your IDE to trace into the provider packages and read the docstrings there
b
i.e. it specifies cluster is an arn... but the actual constructor definition expects a awsx.ecs.Cluster arg
I'd be happy to submit a PR to change the docs... If I knew how to correct it
m
Personally, I have a bias against awsx (crosswalk). It's consistently been more of a pain in the ass than helpful to me.
Unfortunately, in certain cases, it's easier to use 😞 -- such as manipulating Security Groups
b
interesting
m
Another thing to know about awsx, is that many, if not all of the resources contain the AWS primitive resource as a property
e.g. the SecurityGroup will have a
.securityGroup
property that is the underlying aws security group created by the aws provider IIRC.
b
I feel like every resource should implement a method like the one you've shown
.fromExistingId
or
.fromExistingARN
should be part of an interface that is implemented by all resources
just makes sense
@millions-furniture-75402 interesting
m
FWIW, you CAN export your entire object
I'm not sure it's recommended... but it is possible.
The awsx package is not consistent. The API Gateway stuff is a hellscape.
b
@millions-furniture-75402 but doesn't it just export as a plain data object ... and the constructor is expecting an instance of that class (awsx.ecs.Cluster)
m
Hmmm, good point
b
perhaps the constructor can take that plain data object as an argument?
m
Perhaps, I don't remember, been a while.
This example uses the aws package, and the service args take it
b
No I don't need to use awsx I just thought the whole point was it is supposed to save time lol
m
Anecdotally, AWSX has given me PTSD
b
@millions-furniture-75402 Also that link you sent me also leverages awsx
m
Look closer
Copy code
// Create an ECS Cluster
const cluster = new aws.ecs.Cluster("default-cluster");

const service = new awsx.ecs.FargateService("my-service", {
    cluster: cluster.arn,
   ...
});
b
@millions-furniture-75402 good to know
oh interesting
thanks @millions-furniture-75402
m
IIRC awsx can take ARNs or AWS resources instead of awsx resources in some cases.
b
I wonder if it wouldn't make sense to update the docs when/if I get this working so another person doesn't have to go through the same headache figuring this out?
m
It looks like there is an effort to replace the legacy version of awsx, which might be why the docs are out of sync.
b
interesting
m
The awsx resource having the aws resource as a property
You get this figured out?
b
Been busy working on other stuff
but I think I've almost figured it out
will ping you
when I get a chance to get back at it
m
Cool, sounds good.
b
TY for all your help
👍 1