Im shooting for an index file of just pretty 1 lin...
# aws
p
Im shooting for an index file of just pretty 1 lines that create the objects I need
l
What's not working? It looks okay at first glance.
p
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
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
Sure sure one moment
l
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
oh ok one sec
l
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
Untitled.ts
l
Line 11.
p
oh my
l
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
lemme try 😄
l
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
nah its hand built
wait so you mean change the type to Input<string>
l
Yes.
Input<string>
=
string | Output<string>
. which is what you want.
p
Sorry Im still figuring out typescript
so on line 11
Copy code
export class BTnacls extends pulumi.ComponentResource {
    public nacl: aws.ec2.NetworkAcl;
  
    constructor(
        naclname: string,
        vpcID: Input<string>,
        cidr: string,
        opts?: ResourceOptions
    ) {
l
No, just use
Input<string>
, that's the correct type.
p
ah ok so like that then
gotcha
it doesnt like that but Ill fiddle around with it
l
Maybe
pulumi.Input<string>
?
p
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
It's quick to pick up if you have any C# or Java experience.. checkout out typescriptlang.org
p
Thanks a lot!