-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model validation failed (#: required key [Code] not found) [has workaround] #906
Comments
WorkaroundI was able to work around this issue by requiring all changes to const latest = pulumi
.all([graphqlPublicZip.bucket, graphqlPublicZip.key])
.apply(async ([bucket, key]) => {
const result = await aws.s3.getObject({
bucket,
key,
});
return result.versionId;
}); export const graphqlPublic = new awsnative.lambda.Function(
lambdaName,
{
functionName: lambdaName,
role: graphqlPublicRole.arn,
memorySize: 128,
architectures: ["arm64"],
runtime: "nodejs16.x",
handler: "index.handler",
code: {
s3Bucket: lambdaStore.id,
s3Key: graphqlPublicZip.key,
s3ObjectVersion: latest,
},
layers: [
// enable KMS communication
"arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:4",
],
},
{ replaceOnChanges: ["code", "layers"] }
); It's hardly elegant, but it does ensure that the object is being recreated correctly. |
This seems to be specific to awsnative, so I'm going to transfer the issue over to that repo. |
Hi @jakobo - thank you for opening this issue! We really appreciate your diligence in not only providing a reproduction, but also the potential workaround - it seems like a relatively straightforward fix, so we'll try to get this queued up soon. Thanks again! |
This causes the function to fail deployment when function code is updated outside of Pulumi (for example, when code is managed by a separate CI workflow). The workaround replaces function code, which is not an option for a production deployment. I also tried |
I am seeing this same error when simply attempting to update the description on an existing lambda function that includes no additional layers. To reproduce:
Deploying the above as normal with
I would hazard a guess that the cloudcontrol api is expected pulumi to resend the Many thanks for your help. |
This is still happening, in my case when My current workaorund is to update the image tag of the URI to a random string using the Pulumi random package (which also triggers a new image push). Not great. |
This is still happening for me, when Is there any workaround other than deleting and recreating? |
Write-only properties can't even be read internally within the CloudControl service so they must be included in PATCH requests to ensure the updated model validates. - Refactor where we unmarshal inputs to avoid duplicate work. Fixes #906 Might also fix #1243 but there's no code to reproduce the issue.
What happened?
I have an existing lambda funnction using the TypeScript
awsnative
library. I attempted to add the official AWS layer for KMS support (arn:aws:lambda:us-west-2:345057560386:layer:AWS-Parameters-and-Secrets-Lambda-Extension-Arm64:4
).Expected Behavior
pulumi up
runs without issueactual
error: operation error CloudControl: UpdateResource, https response error StatusCode: 400, RequestID: zzzzz, api error ValidationException: Model validation failed (#: required key [Code] not found)
With debug output, the request payload sent to CloudControl is
With the response:
Steps to reproduce
The following lambda configuration will work on the first deploy.
Before a second
pulumi up
, add thelayers
object to the lambda configThen, running
pulumi up
generates the400 Bad Request
errors above.Output of
pulumi about
Additional context
Slack Thread: https://pulumi-community.slack.com/archives/C84L4E3N1/p1683565128664669
Related: hashicorp/terraform-provider-awscc#185 (comment)
keywords: awsnative, lambda, CloudControl, "[Code] not found"
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: