You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(lambda): hide warning if skipPermissions is set (#30060)
### Issue #29887Closes#29887
### Reason for this change
If an user imports a lambda and wants to add permissions a warning is show. This warning should be skippable with the skipPermissions flag.
### Description of how you validated changes
Unit tests for checking if the warning is shown/not shown depending on the value of `skipPermissions` are added.
### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Annotations.of(this).addWarningV2('UnclearLambdaEnvironment',`addPermission() has no effect on a Lambda Function with region=${this.env.region}, account=${this.env.account}, in a Stack with region=${Stack.of(this).region}, account=${Stack.of(this).account}. Suppress this warning if this is is intentional, or pass sameEnvironment=true to fromFunctionAttributes() if you would like to add the permissions.`);
347
+
if(!this._skipPermissions){
348
+
Annotations.of(this).addWarningV2('UnclearLambdaEnvironment',`addPermission() has no effect on a Lambda Function with region=${this.env.region}, account=${this.env.account}, in a Stack with region=${Stack.of(this).region}, account=${Stack.of(this).account}. Suppress this warning if this is is intentional, or pass sameEnvironment=true to fromFunctionAttributes() if you would like to add the permissions.`);
'addPermission() has no effect on a Lambda Function with region=us-west-2, account=123456789012, in a Stack with region=',
261
+
{
262
+
Ref: 'AWS::Region',
263
+
},
264
+
', account=',
265
+
{
266
+
Ref: 'AWS::AccountId',
267
+
},
268
+
'. Suppress this warning if this is is intentional, or pass sameEnvironment=true to fromFunctionAttributes() if you would like to add the permissions. [ack: UnclearLambdaEnvironment]',
269
+
],
270
+
],
271
+
},
272
+
path: '/Default/Imported',
273
+
},
274
+
]);
275
+
});
276
+
226
277
test('applies source account/ARN conditions if the principal has conditions',()=>{
0 commit comments