From b4c08e24b32095645b0df65a32d603b6914e293b Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Wed, 26 Jul 2023 14:45:27 +0200 Subject: [PATCH 1/2] Move field `roleInstance` from `Function` to `CallbackFunction` Fixes https://github.com/pulumi/pulumi-aws/issues/2639 This actually makes the mixin more self-contained, since we previously added a field to a normal pulumi resource, making TS's `lambda.Function` different then Go's `lambda.Function`. With this change, `lambda.Function` is the same in all languages. --- sdk/nodejs/lambda/lambdaMixins.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sdk/nodejs/lambda/lambdaMixins.ts b/sdk/nodejs/lambda/lambdaMixins.ts index 0569836e3ad..451a8aab23f 100644 --- a/sdk/nodejs/lambda/lambdaMixins.ts +++ b/sdk/nodejs/lambda/lambdaMixins.ts @@ -282,6 +282,12 @@ export function createFunctionFromEventHandler( * `AWSXrayWriteOnlyAccess` */ export class CallbackFunction extends LambdaFunction { + /** + * Actual Role instance value for this Function. Will only be set if this function was + * created from [createFunction] + */ + public readonly roleInstance?: iam.Role; + public constructor(name: string, args: CallbackFunctionArgs, opts: pulumi.CustomResourceOptions = {}) { if (!name) { throw new Error("Missing required resource name"); @@ -436,14 +442,3 @@ const lambdaRolePolicy = { }, ], }; -// Mixin the Role we potentially create into the Function instances we return. - -declare module "./function" { - interface Function { - /** - * Actual Role instance value for this Function. Will only be set if this function was - * created from [createFunction] - */ - roleInstance?: iam.Role; - } -} From 2c09c53a812078047021ad9eb01d54218ed52b01 Mon Sep 17 00:00:00 2001 From: Ian Wahbe Date: Wed, 26 Jul 2023 15:24:25 +0200 Subject: [PATCH 2/2] Remove deprecated serverless.Function `serverless.Function` has been deprecated in favor of `lambda.CallbackFunction` since 2018 (https://github.com/pulumi/pulumi-aws/pull/327). Since it depends on the removed functionality, I have bundled its removal. --- provider/resources.go | 5 -- sdk/nodejs/index.ts | 2 - sdk/nodejs/serverless/function.ts | 127 ------------------------------ sdk/nodejs/serverless/index.ts | 5 -- sdk/nodejs/tsconfig.json | 2 - 5 files changed, 141 deletions(-) delete mode 100644 sdk/nodejs/serverless/function.ts delete mode 100644 sdk/nodejs/serverless/index.ts diff --git a/provider/resources.go b/provider/resources.go index 0e6b846d1d8..8e3b7ed6ba0 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -6827,11 +6827,6 @@ func Provider() *tfbridge.ProviderInfo { "s3Mixins.ts", }, }, - "serverless": { - DestFiles: []string{ - "function.ts", - }, - }, "sns": { DestFiles: []string{ "snsMixins.ts", diff --git a/sdk/nodejs/index.ts b/sdk/nodejs/index.ts index a76a1c86e75..561de106bd9 100644 --- a/sdk/nodejs/index.ts +++ b/sdk/nodejs/index.ts @@ -234,7 +234,6 @@ import * as scheduler from "./scheduler"; import * as schemas from "./schemas"; import * as secretsmanager from "./secretsmanager"; import * as securityhub from "./securityhub"; -import * as serverless from "./serverless"; import * as serverlessrepository from "./serverlessrepository"; import * as servicecatalog from "./servicecatalog"; import * as servicediscovery from "./servicediscovery"; @@ -428,7 +427,6 @@ export { schemas, secretsmanager, securityhub, - serverless, serverlessrepository, servicecatalog, servicediscovery, diff --git a/sdk/nodejs/serverless/function.ts b/sdk/nodejs/serverless/function.ts deleted file mode 100644 index 6c6c88c3834..00000000000 --- a/sdk/nodejs/serverless/function.ts +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2016-2018, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import * as pulumi from "@pulumi/pulumi"; -import { Role } from "../iam"; -import * as lambda from "../lambda"; -import * as utils from "../utils"; - -/** - * @deprecated Use [aws.lambda.Context] instead. - */ -export type Context = lambda.Context; - -/** - * [Handler] is the signature for a serverless function that will be invoked each time the AWS - * Lambda is invoked. - * - * @deprecated Use [aws.lambda.Callback] instead. - */ -export type Handler = lambda.Callback; - -/** - * HandlerFactory is the signature for a function that will be called once to produce the serverless - * function that AWS Lambda will invoke. It can be used to initialize expensive state once that can - * then be used across all invocations of the Lambda (as long as the Lambda is using the same warm - * node instance). - * - * @deprecated Use [aws.lambda.CallbackFactory] instead. - */ -export type HandlerFactory = () => Handler; - -/** - * FunctionOptions provides configuration options for the serverless Function. It is effectively - * equivalent to [aws.lambda.FunctionArgs] except with a few important differences documented at the - * property level. For example, [role] is an actual iam.Role instance, and not an ARN. Properties - * like [runtime] are now optional. And some properties (like [code]) are entirely disallowed. - * - * @deprecated Use [aws.lambda.FunctionOptions] instead. - */ -export type FunctionOptions = utils.Overwrite, { - /** - * @deprecated use [callback] instead. - */ - func?: Handler; - - /** - * @deprecated use [callbackFactory] instead. - */ - factoryFunc?: HandlerFactory; - - /** - * The paths relative to the program folder to include in the Lambda upload. Default is `[]`. - * - * @deprecated Use [codePathOptions] instead. - */ - includePaths?: string[]; - - /** - * The packages relative to the program folder to include in the Lambda upload. The version of - * the package installed in the program folder and it's dependencies will all be included. - * Default is `[]`. - * - * @deprecated Use [codePathOptions] instead. - */ - includePackages?: string[]; - - /** - * The packages relative to the program folder to not include the Lambda upload. This can be - * used to override the default serialization logic that includes all packages referenced by - * project.json (except @pulumi packages). Default is `[]`. - * - * @deprecated Use [codePathOptions] instead. - */ - excludePackages?: string[]; -}>; - -/** - * Function is a higher-level API for creating and managing AWS Lambda Function resources - * implemented by a Pulumi lambda expression and with a set of attached policies. - * - * @deprecated Use [lambda.CallbackFunction] instead. - */ -export class Function extends pulumi.ComponentResource { - public readonly options: FunctionOptions; - public readonly lambda: lambda.Function; - public readonly role: Role | undefined; - - /** - * @param func Deprecated. Pass the function as [options.func] or [options.factoryFunc] instead. - */ - constructor(name: string, - options: FunctionOptions, - func?: Handler, - opts?: pulumi.ResourceOptions) { - - super("aws:serverless:Function", name, {}, opts); - - opts = opts || { parent: this }; - - // Migrate old aws-serverless.FunctionOptions forward to lambda.FunctionOptions. - options.callback = options.callback || options.func || func; - options.callbackFactory = options.callbackFactory || options.factoryFunc; - - if (!options.codePathOptions) { - options.codePathOptions = { - extraIncludePaths: options.includePaths, - extraIncludePackages: options.includePackages, - extraExcludePackages: options.excludePackages, - }; - } - - this.lambda = new lambda.CallbackFunction(name, options, { parent: this }); - this.role = this.lambda.roleInstance; - this.options = options; - } -} diff --git a/sdk/nodejs/serverless/index.ts b/sdk/nodejs/serverless/index.ts deleted file mode 100644 index 4308406699d..00000000000 --- a/sdk/nodejs/serverless/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** -// *** Do not edit by hand unless you're certain you know what you are doing! *** - -// Export members: -export * from "./function"; diff --git a/sdk/nodejs/tsconfig.json b/sdk/nodejs/tsconfig.json index 82b733002a4..8e2887bcd92 100644 --- a/sdk/nodejs/tsconfig.json +++ b/sdk/nodejs/tsconfig.json @@ -1723,8 +1723,6 @@ "securityhub/productSubscription.ts", "securityhub/standardsControl.ts", "securityhub/standardsSubscription.ts", - "serverless/function.ts", - "serverless/index.ts", "serverlessrepository/cloudFormationStack.ts", "serverlessrepository/getApplication.ts", "serverlessrepository/index.ts",