`sst remove` is failing to remove my stack with th...
# help
s
sst remove
is failing to remove my stack with the message "construct does not have an associated node. All constructs must extend the "Construct" base class"
It's coming from CDK
Copy code
Error: construct does not have an associated node. All constructs must extend the "Construct" base class
    at Function.of (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/constructs/src/construct.ts:21:13)
    at _lookup (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/stack.ts:91:27)
    at Function.of (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/stack.ts:76:21)
    at Function.getValue (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/context-provider.ts:60:25)
    at Function.valueFromLookup (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/aws-ssm/lib/parameter.ts:212:35)
    at Object.main (/Users/sgeoghegan/dev/knock-attribution-service/stacks/index.js:10:89)
    at Object.<anonymous> (/Users/sgeoghegan/dev/knock-attribution-service/.build/run.js:93:16)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)

There was an error synthesizing your app.
It looks like it has something to do with my SSM lookups
Copy code
// index.js
import { StringParameter } from "@aws-cdk/aws-ssm";

export default function main(app) {
  const ATTRIBUTION_DB: process.env.IS_LOCAL ? process.env.ATTRIBUTION_DB : StringParameter.valueFromLookup(this,process.env.ATTRIBUTION_DB)
// other stuff...

}
ö
Does it take an additional argument?
yeah it does
And kindly note this
this
does not refer to the Construct in the function main, it is either undefined or the global object
so you can do this:
StringParameter.valueFromLookup(app, process.env.ATTRIBUTION_DB)
s
🤦
Thank you!
ö
You’re most welcome
s
Hmm, that didn't do it. New error thought 🙂
Copy code
Error: App at '' should be created in the scope of a Stack, but no Stack found
    at _lookup (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/stack.ts:93:15)
    at Function.of (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/stack.ts:76:21)
    at Function.getValue (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/core/lib/context-provider.ts:60:25)
    at Function.valueFromLookup (/Users/sgeoghegan/dev/knock-attribution-service/node_modules/@aws-cdk/aws-ssm/lib/parameter.ts:212:35)
    at Object.main (/Users/sgeoghegan/dev/knock-attribution-service/stacks/index.js:9:89)
    at Object.<anonymous> (/Users/sgeoghegan/dev/knock-attribution-service/.build/run.js:93:16)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
this worked:
Copy code
// Set default runtime for all functions
  app.setDefaultFunctionProps((stack) =>({
    runtime: "python3.8",
    srcPath: "functions",
    environment:{          
      ATTRIBUTION_DB: process.env.IS_LOCAL ? process.env.ATTRIBUTION_DB : StringParameter.valueFromLookup(stack,process.env.ATTRIBUTION_DB)
    }
  }));
ö
Oh
s
but you were correct, the
this
parameter I was passing was not correct