Is this new? > :x: mycomp-vpc-stack failed: T...
# sst
a
Is this new?
mycomp-vpc-stack failed: The mycomp-vpc-stack stack contains no resources.
I’m using an stack to lookup for the existing VPC… never failed until I did the update?
t
Hm I don't think we changed anything on our end that would have resulted in that. However for situations like this I recommend making a helper function instead of an empty stack since dealing with stacks has more overhead
a
Ok.
Never got that error before, I believe.
Maybe empty stacks were dismissed before.
f
Previously, a stack could never be empty b/c it always had a dummy
AWS::CDK::Metadata
resource.
I think we should add a check for empty stacks at build time, so it fails early. Or add a dummy resource if there’s an legit use case for having empty stacks. What do you think @thdxr?
a
Yeah that sounds like a thing.
Yes, during build is not failing.
t
Ah interesting that makes sense
a
I liked having empty stacks, I mean, just because in future I’m going to add stuff into them.
t
The only thing with empty stacks is they slow down things so I'm leaning towards aligning with the cdk behavior
a
For example, I have a VPC stack… but today only does a lookup for existing vpc… due I don’t want to remove or create existing vpcs.
But tomorrow I would like to refactor it, to actually create the vpc.
Ok @thdxr that makes sense… maybe there is overhead, my stack is only looking and storing a reference.
Check this…
Copy code
export default class VpcStack extends Stack {
  readonly vpc: IVpc;
  readonly securityGroup: ISecurityGroup;

  constructor(scope: App, id: string, props?: StackProps) {
    super(scope, id, props);

    this.vpc = Vpc.fromLookup(this, 'vpc-xxx', {
      vpcName: 'xxx-vpc-bc079560',
    });

    this.securityGroup = SecurityGroup.fromLookup(this, 'sg-xxx', 'sg-xxx');
  }
}
f
Right. Another option would be SST just mark them as deployed successful right away, without actually deploying it through CFN.
a
I just need a reference to be used later… BUT in future this is going to actually create them.
t
The way I approach these situations is to keep these as functions instead of stacks
Copy code
export function Vpc(scope: sst.Stack) {
  return {
    vpc: Vpc.fromLookup(...),
  }
}
f
Oh u can import with the App as the scope?
t
er that was a typo
Fixed
But I hear you on supporting empty stacks. I like the idea of skipping running them through cf deploy
a
@Frank I don’t want to delete my empty stacks, should I downgrade framework version?
Until the empty thing is released?
Or there is other workaround?
f
We will push out a fix by tonite. Yeah, maybe downgrade for now till then.
a
Oh nice, thank you guys.
@thdxr in case I want to use your approach, which is going to be the context?
Because
vpc.fromLookup
need a context, I ben using
this
from the stack.
Can I send it the
app
?
t
It should probably be
this
but it shouldn't matter afaik
Depends what you need, can pass both to the function
a
But if I want to put this function on my
index.ts
?
I think I cant because there is no context?
t
You can place the function anywhere and it can take whatever arguments you need in it. When doing the lookup for the vpc I'd pass in the stack
Copy code
function Helper(app: <http://sst.App|sst.App>, stack: sst.Stack) {
}
a
Ah, I see.
I might wait for the release 👀 /
I’ve reverted to 0.40.0 but still getting the error 😞
f
Hmm.. I will be cutting a release in an hour or so