feat(aws): expose L2 refs for Lambda alias + S3 server-access-log integrations#1102
Merged
Conversation
createLambdaFunction now stashes any aliases it created on the returned function instance under .lambdaAliases, keyed by aliasName. The new FunctionWithAliases type makes this discoverable. Downstream constructs that previously had to import the alias by ARN via Function.fromFunctionArn (which triggers UnclearLambdaEnvironment and silently drops addPermission() invokes) can now consume the real Alias L2 directly, e.g. for LambdaIntegration.
S3BucketProps gains an optional logBucket?: IBucket field alongside the existing logBucketName?: string. When the caller already owns the log destination (created in the same stack), passing the L2 lets CDK attach the log-delivery BucketPolicy directly — clearing the accessLogsPolicyNotAdded warning and eliminating an unnecessary Bucket.fromBucketName import. StaticSite is updated to pass its just-created siteLogBucket through so consumers get this for free. logBucketName remains supported for genuine cross-stack imports where only the destination name is known.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createLambdaFunctionnow stashes the createdAliasinstances on the returnedFunctionunder.lambdaAliases(keyed byaliasName), exposed via a newFunctionWithAliasestype. Lets downstream constructs (e.g.LambdaIntegration) consume the alias L2 directly instead of re-importing by ARN — which triggeredUnclearLambdaEnvironmentwarnings and silently droppedaddPermission()invokes when CDK couldn't prove same-env.S3BucketPropsaccepts an optionallogBucket?: IBucketalongside the existinglogBucketName?: string. When the caller owns the log destination (created in the same stack), passing the L2 lets CDK attach the log-deliveryBucketPolicydirectly — clearing theaccessLogsPolicyNotAddedwarning and removing an unnecessaryBucket.fromBucketNameimport.logBucketNameremains supported for genuine cross-stack imports where only the destination name is known.StaticSite.createSiteBucketnow passes the just-createdsiteLogBucketL2 down to the source-bucket creation so consumers get the wiring fix without any code changes on their side.Notes
logBuckettakes precedence overlogBucketNamewhen both are set.logBucketNameor no log bucket at all see no behavioral change.FunctionWithAliasestype widenscreateLambdaFunction's return; existing assignment toFunctionkeeps working via structural compatibility.Changeset included.