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

Add S3 Bucket to SNS mapping #4120

Closed
AlexeyRaga opened this issue Nov 30, 2015 · 22 comments
Closed

Add S3 Bucket to SNS mapping #4120

AlexeyRaga opened this issue Nov 30, 2015 · 22 comments

Comments

@AlexeyRaga
Copy link

It would be very helpful if Terraform could add event notifications from an S3 Bucket to an SNS topic.
ASW has this ability through the UI and it is also supported by CloudFormation, but not by Terraform as far as I can tell.

@stack72
Copy link
Contributor

stack72 commented Dec 1, 2015

@AlexeyRaga I cannot see, within the UI, a way to hook an S3 bucket up to an SNS Topic

screen shot 2015-12-01 at 13 21 53

Got any more info on how to do this?

@wstaples
Copy link

wstaples commented Dec 3, 2015

From the S3 console click properties and expend the Events section:

untitled

You can also use the cli:
aws s3api get-bucket-notification-configuration --bucket <some_bucket>

The best way to handle this would probably be to add an event property to the aws_s3_bucket resource and users can provide there own JSON.

@dwradcliffe
Copy link
Contributor

Yeah bucket event config would be a big help!

@dwradcliffe
Copy link
Contributor

See also: #3108

@mdevs5531
Copy link

+1 for s3 events -> SQS

@comozo
Copy link

comozo commented Jan 11, 2016

+1 for s3 events -> SNS

@harrisnb
Copy link

+1 for s3 events -> SNS allowing users to provide their own JSON

@dabdine-r7
Copy link

I was able to work around this by combining an idea from @wstaples and the null_resource, a trigger and the local_exec provisioner:

resource "null_resource" "test_bucket_sns_event_notification" {
   triggers {
      bucket = "${aws_s3_bucket.test_bucket.arn}"
   }

   provisioner "local-exec" {
      command = <<EOF
aws s3api put-bucket-notification-configuration --region ${var.region} --bucket ${aws_s3_bucket.test_bucket.bucket} --notification-configuration \
'{
    "TopicConfigurations": [
        {
            "TopicArn": "${aws_sns_topic.some_sns_topic.arn}",
            "Events": [
                "s3:ObjectCreated:*"
            ]
        }
    ]
}'
EOF
   }
}

Obvious pros and cons here, so YMMV.

CONS:

  1. Terraform can't enforce policy configuration in this model so be aware of users hand-modifying the policy via the aws cli OR the aws console.
  2. Requires the aws cli to be installed locally to make use of s3api.

PROS:
It works :P

@dabdine-r7
Copy link

Oh, and +1 for s3 events -> SNS

@sp-ludovic-ivain
Copy link

+1 for s3 events -> SQS :)

@joseph-wortmann
Copy link

+1 for s3 events -> SQS

@gilessteinberg
Copy link

+1 for s3 events -> Lambda

@wincus
Copy link

wincus commented Feb 23, 2016

+1 for s3 events -> SQS

1 similar comment
@falaa
Copy link

falaa commented Mar 2, 2016

+1 for s3 events -> SQS

@egoldschmidt
Copy link

+1

@iceycake
Copy link
Contributor

iceycake commented Mar 5, 2016

S3 Event Notification will look something like this?

resource "aws_s3_bucket" "b" {
  notification {
    lambda {
        event = ""
        function = ""
        filter {
            name = ""
            value = ""
        }
        filter {
            name = ""
            value = ""
        }
    }
    sns {
        event = ""
        topic = ""
        filter {
          name = ""
          value = ""
        }
    }
    sqs {
        event = ""
        queue = ""
        filter {
          name = ""
          value = ""
        }
    }
  }
}

@conorgil
Copy link

conorgil commented Mar 9, 2016

+1 for s3 events -> SQS

@rantav
Copy link

rantav commented Mar 15, 2016

Joining the herd:
+1 for s3 events -> Lambda

@rbachman
Copy link

+1 for s3 events

@curena
Copy link

curena commented Mar 21, 2016

It looks like bucket event notifications are being implemented via #5473

@stack72
Copy link
Contributor

stack72 commented Apr 5, 2016

This has been implemented via #5473 with thanks to @kjmkznr

@stack72 stack72 closed this as completed Apr 5, 2016
@ghost
Copy link

ghost commented Apr 26, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests