I'm trying to create an SSM parameter, but it requ...
# help
m
I'm trying to create an SSM parameter, but it requires a
Construct
. What do I pass?
Copy code
import * as sst from '@serverless-stack/resources'
import * as ssm from '@aws-cdk/aws-ssm'

export default class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props)

    new ssm.StringParameter(
        /* what do I pass here, it requires a Constuct */
    )
}
f
Pass in
this
, which is the stack construct. So this ssm resource belongs to this CloudFormation stack.
Copy code
new ssm.StringParameter(this, "MyParameter", { ... })
m
Copy code
Argument of type 'this' is not assignable to parameter of type 'Construct'.
  Type 'MyStack' is not assignable to type 'Construct'.
    Property 'onValidate' is protected but type 'Construct' is not a class derived from 'Construct'.ts(2345)
Has an update broken this .. my versions are:
Copy code
"devDependencies": {
  "@aws-cdk/assert": "1.95.1",
  "@aws-cdk/aws-ssm": "1.95.1",
  "@types/aws-lambda": "^8.10.73"
},
"dependencies": {
  "@aws-cdk/core": "1.95.1",
  "@serverless-stack/cli": "0.10.6",
  "@serverless-stack/resources": "0.10.6"
}
f
Can you change all the “1.95.1” versions to “1.94.1"?
do a npm/yarn install and try building again?
This worked for me
Copy code
new ssm.StringParameter(this, "Param", {
      stringValue: 'Foo',
    });
m
1.94.1
works,
1.95.1
doesn't
f
hmm.. that’s weird. We will be updating the CDK versions soon.
Btw, use the
add-cdk
command to add cdk dependencies, ie.
Copy code
$ npx sst add-cdk @aws-cdk/aws-ssm
SST will install the supported version and updates your
package.json
r
FYI - I just encountered the same problem with CfnAccessKey
f
Thanks for the headsup @Ross Coundon
Currently SST shows a warning for packages that are of a different CDK version. I wonder if we should throw an error, and forces u to keep the version in sync. 🤔
r
the odd thing here was it complained that the versions were mismatched
Copy code
Mismatched versions of AWS CDK packages. Serverless Stack currently supports 1.94.1. Fix using:

  npm install @aws-cdk/aws-iam@1.94.1 @aws-cdk/core@1.94.1 --save-exact
However, 1.94.1 is the actual version in package json
f
oh.. lemme check how we are checking for versions right now
that’s weird.. i’m looking at the code, SST loads up your
package.json
, loop through each dependency and dev dependency that starts with “@aws-sdk” and check if version is not, in this case, 1.94.1
did u manage to fix it by running
npm install @aws-cdk/aws-iam@1.94.1 @aws-cdk/core@1.94.1 --save-exact
?
r
Weird! The dependencies in package.json look like:
I ran
npx sst add-cdk @aws-cdk/aws-ssm
f
oh it actually expects the exact version, not with the caret
r
ah, makes sense
f
this is annoying.. they are going to restructure CDK in v2.0 and we will be able to add it as a peer dependency by then. Hopefully the version mismatch will be solved.