A developer has deployed an AWS Lambda function named `DataProcessor` in Account A () and configured a Function URL with the authorization type set to `AWS_IAM`. An IAM role named `AppRole` in Account B () needs to invoke this function by sending HTTP requests directly to the Function URL. Which combination of configuration steps will successfully and securely grant `AppRole` the necessary permissions to invoke the Function URL?
- AAdd a resource-based policy to the Lambda function in Account A that grants `lambda:InvokeFunction` permissions to `AppRole`, and attach an identity-based policy to `AppRole` in Account B that allows `lambda:InvokeFunction` on the function ARN in Account A.
- BAttach an identity-based policy to `AppRole` in Account B that allows `lambda:InvokeFunctionUrl` with the Resource element set to the function's HTTP URL, and add a resource-based policy to the Lambda function in Account A that grants `lambda:InvokeFunctionUrl` to Account B.
- Add a resource-based policy to the Lambda function in Account A that grants `lambda:InvokeFunctionUrl` permissions to the Principal `arn:aws:iam::222222222222:role/AppRole`, and attach an identity-based policy to `AppRole` in Account B that allows `lambda:InvokeFunctionUrl` on the function ARN in Account A.Cevap
- DModify the trust policy of `AppRole` in Account B to trust the AWS Lambda service principal (`lambda.amazonaws.com`), and attach an identity-based policy to `AppRole` allowing `sts:AssumeRole` on the Lambda function ARN in Account A.
Cevap
Add a resource-based policy to the Lambda function in Account A that grants `lambda:InvokeFunctionUrl` permissions to the Principal `arn:aws:iam::222222222222:role/AppRole`, and attach an identity-based policy to `AppRole` in Account B that allows `lambda:InvokeFunctionUrl` on the function ARN in Account A.
The correct configuration uses the specific `lambda:InvokeFunctionUrl` action, which is required for Lambda Function URLs. Because the access is cross-account, both the resource-based policy in Account A (which must list the external role ARN as the principal) and the identity-based policy in Account B (which must allow the action on the function ARN) are required.
Adım Adım Çözüm
Anahtar Kavram
Cross-account IAM authorization for AWS Lambda Function URLs
Tahmini Süre:2m 0s