kjagiello / terraform-aws-codepipeline-slack-notifications

Slack notifications for your AWS CodePipelines.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Manual approval notification

dirk39 opened this issue · comments

Hi! what do you think about the support of codepipeline-pipeline-manual-approval-needed event type? In this way can be notified about approval needed. I'm available to code this part.

Let me know

cheers

I believe we already support this through the event_type_ids attribute. See the PR introducing this change for exactly this purpose: #9

looking at the lambda code and the README I don't see support for this event :(

Something like this should work:

module "codepipeline_notifications" {
  source  = "kjagiello/codepipeline-slack-notifications/aws"
  version = "1.1.3"

  name          = "codepipeline-notifications"
  namespace     = "kjagiello"
  stage         = "sandbox"
  slack_url     = "https://hooks.slack.com/services/(...)"
  slack_channel = "#notifications"
  event_type_ids = [
    "codepipeline-pipeline-pipeline-execution-failed",
    "codepipeline-pipeline-pipeline-execution-canceled",
    "codepipeline-pipeline-pipeline-execution-started",
    "codepipeline-pipeline-pipeline-execution-resumed",
    "codepipeline-pipeline-pipeline-execution-succeeded",
    "codepipeline-pipeline-pipeline-execution-superseded",

    # Manual approvals
    "codepipeline-pipeline-manual-approval-needed",
  ]
  codepipelines = [
    aws_codepipeline.example,
  ]
}

The function code should be change because the approval event is a little bit different:

{
    "Records": [
        {
            "EventVersion": "1.0",
            "EventSubscriptionArn": "arn:aws:sns:eu-west-1:11111111:DeveloperNotifications:d3ab24eb-3a37-4b6b-810d-4724ad1a378a",
            "EventSource": "aws:sns",
            "Sns": {
                "Signature": "nsTcPYxyTfqzHhynf7cFLESjxsccT4MeDJKouyZjt9YZFyEp1+j/TiXUx3wLA4z+7r3EuEO5P+hFgUgf6Nx5V7Bv8J1sYswIo2R9f1Zle0HJCByKoBhesCXid4hIswHnq3CeRab/vntlUCSSx/UZXN/1fjEe4kDx5FuLwsgrqhXgrLDOMzrIrAss/2nYk+kRYcUPm6IyTYjmc33/EcR/dZ+Zj5gNXpfcLH6slVT3sQw+1aHTDmoTediB/uxOZi7+7yIs4B6k6O6tkYDKJBnUZit7V6JnNmwEvn6Ed0gOyjKhCSxn1Xx5/SC39mtcA+oVq8B93bqKhSzsxbsYI8iJUg==",
                "MessageId": "6ff02de3-b1de-55b6-8f47-75102439001f",
                "Type": "Notification",
                "TopicArn": "arn:aws:sns:eu-west-1:11111111:DeveloperNotifications",
                "MessageAttributes": {},
                "SignatureVersion": "1",
                "Timestamp": "2021-04-16T13:39:51.88Z",
                "SigningCertUrl": "https://sns.eu-west-1.amazonaws.com/SimpleNotificationService-010a507c1833636cd94bdb98bd93083a.pem",
                "Message": "{\"account\":\"11111111\",\"detailType\":\"CodePipeline Action Execution State Change\",\"region\":\"eu-west-1\",\"source\":\"aws.codepipeline\",\"time\":\"2021-04-16T13:39:46Z\",\"notificationRuleArn\":\"arn:aws:codestar-notifications:eu-west-1:11111111:notificationrule/978d75c8bab46fbc53be39e96592029eedfa4510\",\"detail\":{\"pipeline\":\"DeployDashboard\",\"execution-id\":\"1d86ec1d-b048-470d-a8dc-5a45ac8659f7\",\"stage\":\"DeployApproval\",\"action\":\"Approve\",\"state\":\"STARTED\",\"region\":\"eu-west-1\",\"type\":{\"owner\":\"AWS\",\"provider\":\"Manual\",\"category\":\"Approval\",\"version\":\"1\"},\"version\":4.0},\"resources\":[\"arn:aws:codepipeline:eu-west-1:11111111:DeployDashboard\"],\"additionalAttributes\":{\"externalEntityLink\":\"\",\"customData\":\"\"}}",
                "UnsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:11111111:DeveloperNotifications:d3ab24eb-3a37-4b6b-810d-4724ad1a378a",
                "Subject": ""
            }
        }
    ]
}

As you can see the state, used to determine the color, is always STARTED, but the type nested object is different.

Yeah, I agree. Both the color and the message itself might need some more love. Right now it looks just confusing.
image

I know it's been long overdue, but I have finally found some time to improve the state of approval notifications. See #35.