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
I'm trying to do an S3 putObject using and S3 SDK service integration that references an S3 bucket created in the same serverless.yml file.
I tried to reference the bucket's name using Ref: bucketResource something like as follows:
Write to an S3 Bucket defined in serverless.yml:
Type: TaskResource: arn:aws:states:::aws-sdk:s3:putObjectParameters:
Bucket:
Ref: myBucketReferenceKey: FooBody: BarEnd: true
But it fails to generate the correct IAM policy definition. It generates something like:
(Notice the [object Object] instead of the resolved S3 bucket name).
Whereas it generates the correct IAM permissions when I invoke a Lambda function that references a Lambda function defined in the same `serverless.yml file.
Invoke Lambda defined in serverless.yml:
Type: TaskResource:
Fn::GetAtt: [myLambdaResource, Arn]
Possible Root Cause
From my investigation it looks like the getS3ObjectPermissions() function in compileIamRole.js (here) is too simplistic and just assumes the bucket field specified is a string literal rather than possibly being a reference.
As I mentioned above, references and other intrinsic functions such as Fn::GetAtt are supported for other resources, but it seems the IAM permissions generation for S3 resources is currently lacking this.
Possible Solution
I modified the getS3ObjectPermissions() function locally to implement a possible solution, and it seems to work for me. I have submitted PR #648 for consideration.
I am happy to modify it as needed, or have it superseded by a better solution, but it would be great to fix this.
The text was updated successfully, but these errors were encountered:
danrivett
added a commit
to danrivett/serverless-step-functions
that referenced
this issue
Apr 19, 2025
Summary
I'm trying to do an S3
putObject
using and S3 SDK service integration that references an S3 bucket created in the sameserverless.yml
file.I tried to reference the bucket's name using
Ref: bucketResource
something like as follows:But it fails to generate the correct IAM policy definition. It generates something like:
(Notice the
[object Object]
instead of the resolved S3 bucket name).Whereas it generates the correct IAM permissions when I invoke a Lambda function that references a Lambda function defined in the same `serverless.yml file.
Possible Root Cause
From my investigation it looks like the
getS3ObjectPermissions()
function incompileIamRole.js
(here) is too simplistic and just assumes thebucket
field specified is a string literal rather than possibly being a reference.As I mentioned above, references and other intrinsic functions such as
Fn::GetAtt
are supported for other resources, but it seems the IAM permissions generation for S3 resources is currently lacking this.Possible Solution
I modified the
getS3ObjectPermissions()
function locally to implement a possible solution, and it seems to work for me. I have submitted PR #648 for consideration.I am happy to modify it as needed, or have it superseded by a better solution, but it would be great to fix this.
The text was updated successfully, but these errors were encountered: