when trying to change the template to use nodejs20.x the build is failed
I am trying to create resource provider using Typescipt. I saw that the template is using node 14 - which is very old. i have tried to use node 20. however cfn submit fail with error
command '['npm install --include=optional && sam build --debug --build-dir /Users/liraz/work/skywalker/server/netapp-cfn/export-policy/build --use-container TypeFunction']' returned non-zero exit status 1.
when running the npm install explicitly i am getting an error
Error: NodejsNpmBuilder:NpmPack - NPM Failed: npm notice npm notice New patch version of npm available! 10.2.3 -> 10.2.5 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.5> npm notice Run npm install -g [email protected]to update! npm notice npm ERR! code 2 npm ERR! path /tmp/samcli/source npm ERR! command failed npm ERR! command sh -c npm run build npm ERR! > [email protected] build npm ERR! > npx tsc npm ERR! npm ERR! error TS5033: Could not write file '/tmp/samcli/source/dist/handlers.js': EROFS: read-only file system, open '/tmp/samcli/source/dist/handlers.js'. npm ERR! error TS5033: Could not write file '/tmp/samcli/source/dist/models.js': EROFS: read-only file system, open '/tmp/samcli/source/dist/models.js'. npm ERR! npm WARN config optional Use--omit=optionalto exclude optional dependencies, or npm ERR! npm WARN config--include=optionalto include them. npm ERR! npm WARN config npm ERR! npm WARN config Default value does install optional deps unless otherwise omitted. npm ERR! npm WARN config optional Use--omit=optionalto exclude optional dependencies, or npm ERR! npm WARN config--include=optional` to include them.
npm ERR! npm WARN config
npm ERR! npm WARN config Default value does install optional deps unless otherwise omitted.
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-12-07T21_50_45_696Z-debug-0.log
➜ cfnrp npm install --include=optional && sam build --debug --build-dir /Users/liraz/work/cfnrp/build --use-container TypeFunction
npm WARN config optional Use --omit=optional to exclude optional dependencies, or
npm WARN config --include=optional to include them.
npm WARN config
npm WARN config Default value does install optional deps unless otherwise omitted.
`
moving back to node14 and all is fine
This does not work in > node 14 right now when using docker to run the builds.
https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/issues/123
You have to update your rpdk-config to disable the use of docker (setting use-docker to false and no-docker to true etc)
I haven't been able to replicate this failure on nodejs 18 and 20. Can you also let me know what version of sam you are using?
Correction... I got it replicated. Looking into the issue.
Hey not sure how helpful this is but my coworker and I are also looking into the issue. Right now it looks like the model data is available on the request up until the toModeled function is called https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/blob/98fd8522d1f8a91bd51d7e64fb701a747fd51d6f/src/resource.ts#L375
action: 'CREATE',
request: {
clientRequestToken: 'blah-blah-blah-uuid-uuid',
desiredResourceState: {
AccountId: 'example-account',
Description: 'Example API Key',
Key: 'example-key',
Id: 123,
UserId: 'user-id-123',
UserResourceId: 'user-resource-id-123',
ApiKeySecretId: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:example-secret-123',
DestinationSecretArn: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:destination-secret-123',
TargetResource: { Id: 'resource-id-123', Type: 'kafka' }
},
previousResourceState: {},
logicalResourceIdentifier: null
},
callbackContext: null
@HeatherFlux that looks way beyond the original error I saw above error TS5033: Could not write file '/tmp/samcli/source/dist/models.js': EROFS: read-only file system, open '/tmp/samcli/source/dist/models.js'
I have some options on how to get around this part that I just got working. Little early for a PR but I was able to get cfn submit --dry-run working with nodejs20.x
Did you switch to a local build and still are having issues?
Yep I'm still having issues using the local build option. I'm going to pull the repo and attempt to troubleshoot
Okay, I'm working on a PR to fix the docker portion of the issue. I haven't gotten to your issue as of yet.
@HeatherFlux what is the error you are getting? I want to see if it compares to the one I'm getting now.
Ok here is what I'm getting
MissingRequiredParameter: Missing required key 'SecretId' in params
This gets sent via a call to Secrets Manager using the variable request.desiredResourceState.apiKeySecretId
Now what's wild is the variable I am looking for is on the event data getting logged however that log is in the testEntryPoint method in the resource.ts code.
https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/blob/98fd8522d1f8a91bd51d7e64fb701a747fd51d6f/src/resource.ts#L391
EVENT DATA
{
awsAccountId: 'Blah',
bearerToken: '<REDACTED>',
region: 'us-east-1',
responseEndpoint: null,
action: 'CREATE',
nextToken: null,
resourceType: 'Blah::Blah::Blah',
resourceTypeVersion: "blah"
requestData: {
logicalResourceId: "blah"
resourceProperties: {
DisplayName: "blah"
ApiKeySecretId: "blah"
},
previousResourceProperties: null,
typeConfiguration: null,
callerCredentials: {
accessKeyId: '<REDACTED>',
secretAccessKey: '<REDACTED>',
sessionToken: '<REDACTED>'
},
providerCredentials: {
accessKeyId: '<REDACTED>',
secretAccessKey: '<REDACTED>',
sessionToken: '<REDACTED>'
},
providerLogGroupName:"blah"
systemTags: {
"blah": "blah"
},
previousSystemTags: null,
stackTags: null,
previousStackTags: null
},
stackId: "blah"
callbackContext: null,
snapshotRequested: null,
rollback: null,
driftable: null,
features: {
preventIdempotentResourceAdoption: true,
optimisticStabilizationUluruResourcesV2: true
},
updatePolicy: null,
creationPolicy: null,
serviceModelKey: null
}
We just noticed the break when updating to node >=16
I also noticed that your tsconfig in the repo is pointed towards node14.
@kddejong any update by chance on @HeatherFlux message above?