https://pulumi.com logo
Title
p

purple-train-14007

02/01/2023, 12:15 AM
Im shooting for an index file of just pretty 1 lines that create the objects I need
l

little-cartoon-10569

02/01/2023, 1:43 AM
What's not working? It looks okay at first glance.
p

purple-train-14007

02/01/2023, 1:49 AM
When I create a new VPC object in my index file and then create a new VPC nacl using my firewall class I can’t use the VPC ID. There is a not on the helper function it seems that says you can’t use this for building resources or using Pulumi preview. :/
I can’t even dot source the ID either
l

little-cartoon-10569

02/01/2023, 1:49 AM
That shouldn't be the case. The VPC resource provides an id that you can access.
Is it working in the Subnet you create? It's accessing vpc.id correctly.
Can you post the NACL-creating code, so we can compare?
p

purple-train-14007

02/01/2023, 1:50 AM
Sure sure one moment
l

little-cartoon-10569

02/01/2023, 1:51 AM
Maybe you're accidently implicitly casting
Output<string>
to
any
or
string
?
BTW if it's a large about of code, the text snippet in Slack is good. It highlights syntax, and it makes a collapsible widget
Anything more than about 10 lines looks better in a snippet.
p

purple-train-14007

02/01/2023, 1:52 AM
oh ok one sec
l

little-cartoon-10569

02/01/2023, 1:52 AM
Yep, there's your problem:
vpcID: string
vpcID
is an
Output<string>
. If you cast it to
string
, it'll produce an error message, which is not a valid VPC id.
p

purple-train-14007

02/01/2023, 1:53 AM
Untitled.ts
l

little-cartoon-10569

02/01/2023, 1:53 AM
Line 11.
p

purple-train-14007

02/01/2023, 1:54 AM
oh my
l

little-cartoon-10569

02/01/2023, 1:54 AM
Probably the same for all the Pulumi-fetched values
If you change that to
Input<string>
, it'll work.
And it'll remain testable in your unit test code.
p

purple-train-14007

02/01/2023, 1:54 AM
lemme try 😄
l

little-cartoon-10569

02/01/2023, 1:55 AM
You'll need to do that for
cidr
, assuming that's calculated by AWSX.
If it's from config, or hardcoded, you'll be fine.
p

purple-train-14007

02/01/2023, 1:55 AM
nah its hand built
wait so you mean change the type to Input<string>
l

little-cartoon-10569

02/01/2023, 1:56 AM
Yes.
Input<string>
=
string | Output<string>
. which is what you want.
p

purple-train-14007

02/01/2023, 1:57 AM
Sorry Im still figuring out typescript
so on line 11
export class BTnacls extends pulumi.ComponentResource {
    public nacl: aws.ec2.NetworkAcl;
  
    constructor(
        naclname: string,
        vpcID: Input<string>,
        cidr: string,
        opts?: ResourceOptions
    ) {
l

little-cartoon-10569

02/01/2023, 1:58 AM
No, just use
Input<string>
, that's the correct type.
p

purple-train-14007

02/01/2023, 1:58 AM
ah ok so like that then
gotcha
it doesnt like that but Ill fiddle around with it
l

little-cartoon-10569

02/01/2023, 1:59 AM
Maybe
pulumi.Input<string>
?
p

purple-train-14007

02/01/2023, 1:59 AM
yeah I read the message lol
needed to import it directly from the pulumi library
Ill get good at this language one day...just need more practice
l

little-cartoon-10569

02/01/2023, 2:01 AM
It's quick to pick up if you have any C# or Java experience.. checkout out typescriptlang.org
p

purple-train-14007

02/01/2023, 2:03 AM
Thanks a lot!