-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable preview for create and update
Currently if you update a resource, all outputs are shown as computed during preview. This means that downstream resources might show a replacement in the plan if they are using one of those output values. There are some outputs that we know will not change unless the resource is replaced (I'm referring to these as "stable" outputs). For stable outputs we can copy the value from the state in order to show an accurate preview. The problem is that the CCAPI schema has no way of determining programmatically which outputs are stable and which are not. Because of this, this PR introduces a heuristic to determine if an output is a stable output. - Is the value a `readOnlyProperty` in the schema? This indicates that it is a computed output property - Is the property the resource `id`, `arn` or `name`? If the id, arn, or name is a computed property then we can assume that it is a stable property. I don't know of any cases where these change outside of a resource replacement. This is not 100% coverage of stable properties, but it should get us most of the impactful properties. To get close to 100% coverage we will probably need a schema overlay where we can contribute to mapping these stable properties for each resource. closes #1141
- Loading branch information
Showing
16 changed files
with
9,261 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/bin/ | ||
/node_modules/ | ||
handler.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: aws-native-stable-outputs-preview | ||
runtime: nodejs | ||
description: An example program to test stable outputs during preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const handler = async () => { | ||
return { | ||
statusCode: 200, | ||
body: JSON.stringify({ | ||
message: "Hello World!", | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as pulumi from '@pulumi/pulumi'; | ||
import * as path from 'path'; | ||
import * as ccapi from "@pulumi/aws-native"; | ||
import * as aws from '@pulumi/aws'; | ||
import { zipDirectory } from './zip'; | ||
|
||
const config = new pulumi.Config(); | ||
const desc = config.get('lambdaDescription') ?? 'test lambda'; | ||
const role = new ccapi.iam.Role('lambda-role', { | ||
assumeRolePolicyDocument: { | ||
Version: "2012-10-17", | ||
Statement: [ | ||
{ | ||
Effect: "Allow", | ||
Principal: { | ||
Service: "lambda.amazonaws.com", | ||
}, | ||
Action: "sts:AssumeRole", | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
|
||
const bucket = new ccapi.s3.Bucket('bucket'); | ||
const object = new aws.s3.BucketObjectv2( | ||
'object', | ||
{ | ||
source: zipDirectory(path.join(__dirname, 'app'), 'handler.zip'), | ||
bucket: bucket.bucketName.apply(bucket => bucket!), | ||
key: 'handler.zip', | ||
}, | ||
); | ||
const handler = new ccapi.lambda.Function('my-function', { | ||
code: { | ||
s3Bucket: bucket.bucketName.apply(bucket => bucket!), | ||
s3Key: object.key, | ||
}, | ||
description: desc, | ||
runtime: 'nodejs20.x', | ||
handler: 'index.handler', | ||
role: role.arn, | ||
}); | ||
|
||
new ccapi.lambda.Permission('chall-permission', { | ||
functionName: handler.arn, | ||
action: 'lambda:InvokeFunction', | ||
principal: 's3.amazonaws.com', | ||
}); |
Oops, something went wrong.