Aws step function deployment log access issue

Viewed 1569

I am running into Some permissions issue i am not able to figure out.

The step function deployment fails because of error:

Error: AccessDeniedException: The state machine IAM Role is not authorized to access the Log Destination 10:12:19 status code: 400, request id: ff46f8c0-fcc8-4190-ba6a-13f5ab617c78 10:12:19
10:12:19 on step_function.tf line 1, in resource "aws_sfn_state_machine" "oss_integration_data_process_sf": 10:12:19 1: resource "aws_sfn_state_machine" "os_int_data_process_sf" {

funny thing is, it only happens to one lambda while all lambdas have same prefix and we have step function give permissions as: { "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "logs:AssociateKmsKey", "logs:CreateLogDelivery", "logs:GetLogDelivery", "logs:UpdateLogDelivery", "logs:DeleteLogDelivery", "logs:ListLogDeliveries", "logs:PutResourcePolicy", "logs:DescribeResourcePolicies", "logs:DescribeLogGroups" ], "Resource": [ "arn:aws:logs:us-east-1:XXXX:log-group:*/*" ], "Effect": "Allow" } i can run the lambda after deployment and see CW log stream with lambda name is getting created.

2 Answers

I faced the same error The state machine IAM Role is not authorized to access the Log Destination when using a cloudformation template, but the actual problem was that the YAML field CloudWatchLogsLogGroup was misconfigured.

So I updated it to use the syntax below and it all worked.

  StateMachine:
    Type: AWS::Serverless::StateMachine
    DependsOn: 
      - LogGroup
      - CustomRole
    Properties:
      Name: StateMachine
      Role: !Sub arn:aws:iam::${AWS::AccountId}:role/CustomRole
      Logging:
        Destinations:
          - CloudWatchLogsLogGroup: 
              LogGroupArn: !GetAtt LogGroup.Arn          
        IncludeExecutionData: true
        Level: ALL

Nonetheless, I think the AWS documentation is very confusing on this topic.

Related