Skip to content

Commit 5ec86d0

Browse files
authored
docs(aws-custom-resource): explain deviating policy names (#19458)
Some API calls do not require the exact corresponding IAM permissions. We don't have a mapping to do this properly, so we have to punt to the user (and have to make them aware of this). Relates to #19355. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8dd93a8 commit 5ec86d0

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

packages/@aws-cdk/custom-resources/README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ This sample demonstrates the following concepts:
354354

355355
### Customizing Provider Function name
356356

357-
In multi-account environments or when the custom resource may be re-utilized across several
357+
In multi-account environments or when the custom resource may be re-utilized across several
358358
stacks it may be useful to manually set a name for the Provider Function Lambda and therefore
359359
have a predefined service token ARN.
360360

@@ -401,9 +401,19 @@ the `installLatestAwsSdk` prop to `false`.
401401
You must provide the `policy` property defining the IAM Policy that will be applied to the API calls.
402402
The library provides two factory methods to quickly configure this:
403403

404-
* **`AwsCustomResourcePolicy.fromSdkCalls`** - Use this to auto-generate IAM Policy statements based on the configured SDK calls.
405-
Note that you will have to either provide specific ARN's, or explicitly use `AwsCustomResourcePolicy.ANY_RESOURCE` to allow access to any resource.
406-
* **`AwsCustomResourcePolicy.fromStatements`** - Use this to specify your own custom statements.
404+
* **`AwsCustomResourcePolicy.fromSdkCalls`** - Use this to auto-generate IAM
405+
Policy statements based on the configured SDK calls. Keep two things in mind
406+
when using this policy:
407+
* This policy variant assumes the IAM policy name has the same name as the API
408+
call. This is true in 99% of cases, but there are exceptions (for example,
409+
S3's `PutBucketLifecycleConfiguration` requires
410+
`s3:PutLifecycleConfiguration` permissions, Lambda's `Invoke` requires
411+
`lambda:InvokeFunction` permissions). Use `fromStatements` if you want to
412+
do a call that requires different IAM action names.
413+
* You will have to either provide specific ARNs, or explicitly use
414+
`AwsCustomResourcePolicy.ANY_RESOURCE` to allow access to any resource.
415+
* **`AwsCustomResourcePolicy.fromStatements`** - Use this to specify your own
416+
custom statements.
407417

408418
The custom resource also implements `iam.IGrantable`, making it possible to use the `grantXxx()` methods.
409419

packages/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts

+7
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ export class AwsCustomResourcePolicy {
199199
*
200200
* Each SDK call with be translated to an IAM Policy Statement in the form of: `call.service:call.action` (e.g `s3:PutObject`).
201201
*
202+
* This policy generator assumes the IAM policy name has the same name as the API
203+
* call. This is true in 99% of cases, but there are exceptions (for example,
204+
* S3's `PutBucketLifecycleConfiguration` requires
205+
* `s3:PutLifecycleConfiguration` permissions, Lambda's `Invoke` requires
206+
* `lambda:InvokeFunction` permissions). Use `fromStatements` if you want to
207+
* do a call that requires different IAM action names.
208+
*
202209
* @param options options for the policy generation
203210
*/
204211
public static fromSdkCalls(options: SdkCallsPolicyOptions) {

0 commit comments

Comments
 (0)