[X] I have searched existing issues, it hasn't been reported yet
Issue description
Ever since I have used serverless framework (a couple of years, since early v2 versions), deploying individual functions did not work for me. The same error always occurs, for all my stacks, even though full stack deployments of the exact same configuration are not a problem.
Concretely, on deploying an individual function, the following message appears: Cannot read properties of undefined (reading '0')
It appears that "deploy-function.js" "normalizeArnRole" accepts a role, and attempts to extract the arn of the role. It does so based on this line:
const data = await this.provider.request('IAM', 'getRole', {
RoleName: role['Fn::GetAtt'][0],
});
However, when I log the input received for my function, it is: { 'Fn::ImportValue': 'myRoleArnReference' }
If I hardcode the ARN into the configuration instead of using the !ImportValue statement, the deployment works fine.
(.venv) [ec2-user@ip-10-0-2-64 STACK]$ sls deploy function --stage dev -f my_function
Running "serverless" from node_modules
Deploying function my_function to stage dev (eu-central-1)
✔ Function code deployed (7s)
Environment: linux, node 17.6.0, framework 3.34.0 (local) 3.34.0v (global), plugin 6.2.3, SDK 4.3.2
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
TypeError: Cannot read properties of undefined (reading '0')
at AwsDeployFunction.normalizeArnRole (/home/ec2-user/corp-mob/node_modules/serverless/lib/plugins/aws/deploy-function.js:146:35)
at AwsDeployFunction.updateFunctionConfiguration (/home/ec2-user/corp-mob/node_modules/serverless/lib/plugins/aws/deploy-function.js:413:32)
at deploy:function:deploy (/home/ec2-user/corp-mob/node_modules/serverless/lib/plugins/aws/deploy-function.js:60:20)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async PluginManager.runHooks (/home/ec2-user/corp-mob/node_modules/serverless/lib/classes/plugin-manager.js:530:9)
at async PluginManager.invoke (/home/ec2-user/corp-mob/node_modules/serverless/lib/classes/plugin-manager.js:564:9)
at async PluginManager.run (/home/ec2-user/corp-mob/node_modules/serverless/lib/classes/plugin-manager.js:604:7)
at async Serverless.run (/home/ec2-user/corp-mob/node_modules/serverless/lib/serverless.js:179:5)
at async /home/ec2-user/corp-mob/node_modules/serverless/scripts/serverless.js:834:9
1 deprecation found: run 'serverless doctor' for more details
Are you certain it's a bug?
Are you using the latest plugin release?
Is there an existing issue for this?
Issue description
Ever since I have used serverless framework (a couple of years, since early v2 versions), deploying individual functions did not work for me. The same error always occurs, for all my stacks, even though full stack deployments of the exact same configuration are not a problem. Concretely, on deploying an individual function, the following message appears: Cannot read properties of undefined (reading '0')
It appears that "deploy-function.js" "normalizeArnRole" accepts a role, and attempts to extract the arn of the role. It does so based on this line:
However, when I log the input received for my function, it is:
{ 'Fn::ImportValue': 'myRoleArnReference' }
If I hardcode the ARN into the configuration instead of using the !ImportValue statement, the deployment works fine.Any help is very much appreciated.
Service configuration (serverless.yml) content
Command name and used flags
sls deploy function --stage dev -f my_function
Command output
Environment information