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

Integrate data account S3 events to OrcaBus event source SQS #434

Closed
victorskl opened this issue Jun 11, 2024 · 9 comments · Fixed by #436, umccr/orcabus#351, #438, #439 or #443
Closed

Integrate data account S3 events to OrcaBus event source SQS #434

victorskl opened this issue Jun 11, 2024 · 9 comments · Fixed by #436, umccr/orcabus#351, #438, #439 or #443
Assignees
Labels
feature New feature or request

Comments

@victorskl
Copy link
Member

Context:

Find a solution to send S3 events from data account to beta(dev)|gamma(stg)|prod.

Couple of ways possible with EventBridge to EventBridge cross accounts integration.

See
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-cross-account.html

Actions:

@victorskl victorskl added the feature New feature or request label Jun 11, 2024
@victorskl
Copy link
Member Author

This integration task in the critical path for OrcaBus release Phase 1.

@victorskl
Copy link
Member Author

Amazon EventBridge - Routing events to buses in other AWS accounts
https://www.youtube.com/watch?v=pX_xIW_EuCE

@victorskl
Copy link
Member Author

Simplifying cross-account access with Amazon EventBridge resource policies
https://aws.amazon.com/blogs/compute/simplifying-cross-account-access-with-amazon-eventbridge-resource-policies/

@reisingerf
Copy link
Member

Started working on this on the feature/data-s3-event-forward branch

@reisingerf
Copy link
Member

This will need a resource policy counterpart on the target event bus(es) to allow PutEvents from the source (data) account
=> OrcaBus CDK update

@reisingerf
Copy link
Member

Changes to OrcaBus event bus are on the update/x-account-events branch of the orcabus repo.

@victorskl
Copy link
Member Author

Let us pair coding and complete this together tomorrow, Flo.

@victorskl
Copy link
Member Author

Caveat 1:

  • When we integrate our BYOB bucket to ICAv2 project as underlay storage configuration, ICAv2 subscribes couple of bucket notifications to our buckets.
  • These bucket notification subscription are not in our control.
  • When we also want to integrate our bucket notification to EventBridge, we need to turn it on the boolean flag.
  • The relevant terraform syntax are as follows.

# NOTE: don't control notification settings from TF, as some is controlled by ICA
# resource "aws_s3_bucket_notification" "development_data" {
# bucket = aws_s3_bucket.development_data.id
# eventbridge = true
# }

  • Note that we have commented out the TF code. The reason being as follows.

NOTE:
S3 Buckets only support a single notification configuration. Declaring multiple aws_s3_bucket_notification resources to the same S3 Bucket will cause a perpetual difference in configuration. See the example "Trigger multiple Lambda functions" for an option.
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_notification

  • Basically we do not wish to undo nor clash with bucket notification with ICAv2 BYOB integration.
  • For now, we simply handle turning on EventBridge bucket notification manually.

@victorskl
Copy link
Member Author

Caveat 2:

  • Refer to AWS doc, we are following EventBridge to EventBridge cross account integration.
  • There are source account and target account.
  • At source account (UoM data account) we configure terraform to forward S3 events to target. These code block.
  • At target account EventBridge, we still have to allow events from the source. This has to configure permission policy at designated target bus. In this case, we are targeting to "default" bus at destination. As follows.

target_event_bus_arn_dev = "arn:aws:events:ap-southeast-2:${local.account_id_dev}:event-bus/default"

  • Since destination bus is AWS EventBridge "default" bus, we configure the permission, manually. As follows.

AWS Console > EventBridge > Event buses > default > Permissions

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "AllowDataAccountToPutEvents",
    "Effect": "Allow",
    "Principal": {
      "AWS": "arn:aws:iam::<DATA_ACCOUNT_ID>:root"
    },
    "Action": "events:PutEvents",
    "Resource": "arn:aws:events:ap-southeast-2:<DEV_ACCOUNT_ID>:event-bus/default"
  }]
}

victorskl added a commit that referenced this issue Jun 14, 2024
… ctTSOv2 result

* While building OrcaBus actively, we use current Portal to show ctTSOv2 output as new tab.
  * #434
  * umccr/data-portal-apis#684

* Once new output path convention is stable, we can statically filter prefix only to subscribe cttsov2.
  * umccr/orcabus#350

* Related FileManager PR
  * umccr/orcabus#351
victorskl added a commit to umccr/data-portal-apis that referenced this issue Jun 21, 2024
* Updated S3 event parser to handle ObjectCreated and ObjectDeleted come
  through EventBridge event envelope.
* Added relevant unit test cases as guard-rail around parser logic
* Part of story #684
* Related umccr/infrastructure#434
victorskl added a commit that referenced this issue Jul 2, 2024
* Updated policy allow FileManager role for bucket event ingestion
* To follow up any caveats mentioned in #434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment