Skip to content
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

(lambda): Remove requirement to call currentVersion in order for currentVersionOptions to take effect #23002

Closed
SamStephens opened this issue Nov 20, 2022 · 3 comments · Fixed by #23225
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@SamStephens
Copy link
Contributor

Describe the bug

As per #13731, specifying currentVersionOptions for a Function has no effect unless currentVersion is invoked.

It's easy to see why this is with cdk diff, because these options actually apply to a brand new AWS::Lambda::Version resource that doesn't exist unless currentVersion is invoked. But it's a confusing behavior, and there doesn't seem to be any scenario where a user would specify currentVersionOptions for a Function and not want a AWS::Lambda::Version resource to be created with those options.

Expected Behavior

Specifying currentVersionOptions to provide options for the current version of the Lambda Function without any subsequent interaction being required.

Current Behavior

Specifying currentVersionOptions for a Function has no effect unless the currentVersion method is called.

Reproduction Steps

(Copied from #13731).

export class LambdaAutoScalingStack extends cdk.Stack {
    constructor(scope: cdk.App, id: string) {
        super(scope, id);

        new lambda.Function(this, 'lambda1', {
            code: new lambda.InlineCode('exports.handler = async () => { console.log(\'hello world\'); };'),
            handler: 'index.handler',
            runtime: lambda.Runtime.NODEJS_10_X,
            currentVersionOptions: {
                provisionedConcurrentExecutions: 3
            }
        })

    }
}

Does not configure provisioned concurrency for the current version of the function.

export class LambdaAutoScalingStack extends cdk.Stack {
    constructor(scope: cdk.App, id: string) {
        super(scope, id);

        new lambda.Function(this, 'lambda1', {
            code: new lambda.InlineCode('exports.handler = async () => { console.log(\'hello world\'); };'),
            handler: 'index.handler',
            runtime: lambda.Runtime.NODEJS_10_X,
            currentVersionOptions: {
                provisionedConcurrentExecutions: 3
            }
        });
        fn.currentVersion;

    }
}

Does configure provisioned concurrency for the current version of the function.

Possible Solution

Possibly, just something simply like implicitly calling currentVersion in the constructor if currentVersionOptions is not null.

Additional Information/Context

No response

CDK CLI Version

2.48.0

Framework Version

No response

Node.js Version

v16.15.1

OS

Ubuntu (Windows Subsystem for Linux)

Language

Typescript, Python, .NET, Java, Go

Language Version

No response

Other information

No response

@SamStephens SamStephens added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2022
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 20, 2022
@peterwoodworth peterwoodworth added p2 feature-request A feature should be added or improved. effort/small Small work item – less than a day of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 26, 2022
@peterwoodworth
Copy link
Contributor

I think it sounds reasonable to create a current version if currentVersionOptions are supplied. Thanks for the feature request

I am marking this issue as p2, which means that we are unable to work on this immediately.

We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. You can reach out to the cdk.dev community on Slack to solicit support for reprioritization.

Check out our contributing guide if you're interested in contributing yourself - there's a low chance the team will be able to address this soon but we'd try to take a look at a PR

@mergify mergify bot closed this as completed in #23225 Dec 5, 2022
mergify bot pushed a commit that referenced this issue Dec 5, 2022
…et (#23225)

## Description
Specifying `currentVersionOptions` for a `Function` has no effect unless the `currentVersion` method is called.

## Solution
when defining a `currentVersionOptions` a new version will be created automatically, without the need to execute `currentVersion` method.

Fixes #23002 
----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Dec 5, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

brennanho pushed a commit to brennanho/aws-cdk that referenced this issue Dec 9, 2022
…et (aws#23225)

## Description
Specifying `currentVersionOptions` for a `Function` has no effect unless the `currentVersion` method is called.

## Solution
when defining a `currentVersionOptions` a new version will be created automatically, without the need to execute `currentVersion` method.

Fixes aws#23002 
----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
brennanho pushed a commit to brennanho/aws-cdk that referenced this issue Jan 20, 2023
…et (aws#23225)

## Description
Specifying `currentVersionOptions` for a `Function` has no effect unless the `currentVersion` method is called.

## Solution
when defining a `currentVersionOptions` a new version will be created automatically, without the need to execute `currentVersion` method.

Fixes aws#23002 
----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
brennanho pushed a commit to brennanho/aws-cdk that referenced this issue Feb 22, 2023
…et (aws#23225)

## Description
Specifying `currentVersionOptions` for a `Function` has no effect unless the `currentVersion` method is called.

## Solution
when defining a `currentVersionOptions` a new version will be created automatically, without the need to execute `currentVersion` method.

Fixes aws#23002 
----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@SamStephens
Copy link
Contributor Author

The fix for this was reverted by #23636, as the original fix

breaks the case where a user both:

  • Specifies currentVersionOptions
  • Never calls currentVersion but instead creates a Version object directly.

In that case, 2 Version resources are created, but the second one fails because Lambda will not allow creating a new Version if nothing changed since the last Version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
3 participants