Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling Step Function Logging To CloudWatch #12192

Closed
grahamjenson opened this issue Feb 27, 2020 · 20 comments
Closed

Enabling Step Function Logging To CloudWatch #12192

grahamjenson opened this issue Feb 27, 2020 · 20 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sfn Issues and PRs that pertain to the sfn service.

Comments

@grahamjenson
Copy link
Contributor

grahamjenson commented Feb 27, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I would like logging from Step Functions to CloudWtch logs enabled as described here https://aws.amazon.com/about-aws/whats-new/2020/02/aws-step-functions-supports-cloudwatch-logs-standard-workflows/

This should include the log_level, include_execution_data, cloud_watch_log_group options

References

https://aws.amazon.com/about-aws/whats-new/2020/02/aws-step-functions-supports-cloudwatch-logs-standard-workflows/

@grahamjenson grahamjenson added the enhancement Requests to existing resources that expand the functionality or scope. label Feb 27, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Feb 27, 2020
@ewbankkit
Copy link
Contributor

@grahamjenson
Copy link
Contributor Author

Cheers @ewbankkit for the quick reply!

@grahamjenson
Copy link
Contributor Author

Now that #12128 has been merged any word on this feature?

@grahamjenson
Copy link
Contributor Author

This looks to be implemented by #11570

@ewbankkit
Copy link
Contributor

@grahamjenson Yes, #11570 seems to address this; The only change required there is in the documentation noting that logging_configuration is only valid for EXPRESS workflows - That can now be removed.

@grahamjenson
Copy link
Contributor Author

@ewbankkit I have submitted #12249 which is a branch off the previous PR so with the requested changes.

@mmritesh
Copy link

By when can we expect this feature to be out??

@DrFaust92 DrFaust92 added the service/sfn Issues and PRs that pertain to the sfn service. label May 21, 2020
@michelleyang111
Copy link

michelleyang111 commented Jun 4, 2020

Hi @DrFaust92, and @ewbankkit, what value should i pass to type and logging_configuration to step function in terraform? I can't find the information online.

@ramakrishna2324
Copy link

is there any step in terraform to add logging_configuration to stepfunction

@kevindixon
Copy link

Can anyone provide an update on this issue? Any chance of an ETA?

@men6288
Copy link

men6288 commented Nov 12, 2020

Plus 1 on this one, would be great to have

@ramakrishna2324
Copy link

I found a method in cloud formation. using that method to enable log configuration.

@trevjonez
Copy link

I ended up using a provisioner "local-exec" and a few template files to workaround this issue.

aws stepfunctions update-state-machine \
  --state-machine-arn '${state-machine-arn}' \
  --logging-configuration='${logging-configuration}' \
  --no-cli-pager

render this json and pass it as the logging-configuration in the bash template.

{
  "level": "ALL",
  "includeExecutionData": true,
  "destinations": [
    {
      "cloudWatchLogsLogGroup": {
        "logGroupArn": "${log-group}:*"
      }
    }
  ]
}

@lu-liu-rft
Copy link

I found a method in cloud formation. using that method to enable log configuration.

Hi can you please share the approach by using Cloudwatch? Many thanks.

@lu-liu-rft
Copy link

Update request + 1

From the Terraform doc here: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sfn_state_machine
Seems like this issue hasn't been resolved or the doc hasn't been updated.

@lu-liu-rft
Copy link

Also can we enable X-ray for stepfunction in Terraform?

@lu-liu-rft
Copy link

I ended up using a provisioner "local-exec" and a few template files to workaround this issue.

aws stepfunctions update-state-machine \
  --state-machine-arn '${state-machine-arn}' \
  --logging-configuration='${logging-configuration}' \
  --no-cli-pager

render this json and pass it as the logging-configuration in the bash template.

{
  "level": "ALL",
  "includeExecutionData": true,
  "destinations": [
    {
      "cloudWatchLogsLogGroup": {
        "logGroupArn": "${log-group}:*"
      }
    }
  ]
}

Hi are you using 'null_resource'? Just wondering how you specified triggers parameter? I keep getting error A reference to a resource type must be followed by at least one attributeaccess, specifying the resource name.

@toddlers
Copy link

@lu-liu-rft here is the working example with x-ray

resource "aws_sfn_state_machine" "sfn_state_machine" {
  name     = "mystatemachine"
  role_arn = "arn:aws:iam::1234567890:role/service-role/StepFunctions-MyStateMachine-role-a6146d54"

  definition = <<EOF
{
  "Comment": "A Hello World example of the Amazon States Language using an AWS Lambda Function",
  "StartAt": "HelloWorld",
  "States": {
    "HelloWorld": {
      "Type": "Pass",
      "End": true
    }
  }
}
EOF
}

resource "aws_cloudwatch_log_group" "yada" {
  name = "/aws/vendedlogs/states/myloggroup"
}

resource "null_resource" "enable_step_function_logging" {
      triggers = {
    state_machine_arn  = aws_sfn_state_machine.sfn_state_machine.arn
    logs_params=<<PARAMS
    {
        "level":"ALL",
        "includeExecutionData":true,
        "destinations":[
            {
                "cloudWatchLogsLogGroup":{
                    "logGroupArn":"${aws_cloudwatch_log_group.yada.arn}:*"
                    }
                }
            ]
            }
    PARAMS
    }
  provisioner "local-exec" {
    command = <<EOT
set -euo pipefail

aws stepfunctions update-state-machine --state-machine-arn ${self.triggers.state_machine_arn}  --tracing-configuration enabled=true --logging-configuration='${self.triggers.logs_params}'

EOT
    # interpreter = ["bash"]
  }
}

@ewbankkit
Copy link
Contributor

This has been implemented via #12249 and released in v3.27.0 of the Terraform AWS Provider.

@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Feb 6, 2021
@ghost
Copy link

ghost commented Mar 8, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/sfn Issues and PRs that pertain to the sfn service.
Projects
None yet
Development

No branches or pull requests

10 participants