-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
173 additions
and
33 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
65 changes: 52 additions & 13 deletions
65
internal/components/src/components/function-code-updater.ts
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 |
---|---|---|
@@ -1,19 +1,58 @@ | ||
import { STSClient, GetCallerIdentityCommand } from "@aws-sdk/client-sts"; | ||
import pulumi from "@pulumi/pulumi"; | ||
import { | ||
LambdaClient, | ||
UpdateFunctionCodeCommand, | ||
} from "@aws-sdk/client-lambda"; | ||
|
||
class Provider implements util.dynamic.ResourceProvider { | ||
async create(): Promise<util.dynamic.CreateResult> { | ||
const client = new STSClient(); | ||
const identity = await client.send(new GetCallerIdentityCommand({})); | ||
return { id: "foo", outs: { account: identity.Account } }; | ||
} | ||
export interface FunctionCodeUpdaterInputs { | ||
s3Bucket: pulumi.Input<string>; | ||
s3Key: pulumi.Input<string>; | ||
functionName: pulumi.Input<string>; | ||
} | ||
|
||
interface Inputs { | ||
s3Bucket: string; | ||
s3Key: string; | ||
functionName: string; | ||
} | ||
|
||
export class FunctionCodeUpdater extends util.dynamic.Resource { | ||
account!: util.Output<string>; | ||
constructor(name: string) { | ||
super(new Provider(), name, { account: undefined }); | ||
class Provider implements pulumi.dynamic.ResourceProvider { | ||
async create(inputs: Inputs): Promise<pulumi.dynamic.CreateResult> { | ||
const client = new LambdaClient(); | ||
await client.send( | ||
new UpdateFunctionCodeCommand({ | ||
FunctionName: inputs.functionName, | ||
S3Bucket: inputs.s3Bucket, | ||
S3Key: inputs.s3Key, | ||
}) | ||
); | ||
return { id: "foo" }; | ||
} | ||
|
||
async update( | ||
id: string, | ||
olds: Inputs, | ||
news: Inputs | ||
): Promise<pulumi.dynamic.UpdateResult> { | ||
const client = new LambdaClient(); | ||
await client.send( | ||
new UpdateFunctionCodeCommand({ | ||
FunctionName: news.functionName, | ||
S3Bucket: news.s3Bucket, | ||
S3Key: news.s3Key, | ||
}) | ||
); | ||
return {}; | ||
} | ||
} | ||
|
||
//const updater = new FunctionCodeUpdater("foo"); | ||
//export const account = updater.account; | ||
export class FunctionCodeUpdater extends pulumi.dynamic.Resource { | ||
account!: pulumi.Output<string>; | ||
constructor( | ||
name: string, | ||
args: FunctionCodeUpdaterInputs, | ||
opts?: pulumi.CustomResourceOptions | ||
) { | ||
super(new Provider(), name, args, opts); | ||
} | ||
} |
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