How to extend AWS CDK with non AWS Resources during deploy

508 views Asked by At

I would like to automate setting up the collection of AWS Application Load Balancer logs using Sumo Logic as documented here:

https://help.sumologic.com/07Sumo-Logic-Apps/01Amazon_and_AWS/AWS_Elastic_Load_Balancer_-_Application/01_Collect_Logs_for_the_AWS_Elastic_Load_Balancer_Application_App

This involves creating a bucket, creating a Sumo Logic hosted collector with an S3 source, taking the URL of the collector source provided by Sumo Logic and then creating an SNS Topic with an HTTP subscription where the subscription URL is the one provided by the Sumo Logic source.

The issue with this is that the SumoLogic source URL is not known at synthesis time. The Bucket must be deployed, then the Sumlogic things created, then the SNS topic created.

As best I can figure, I will have to do this through separate invocations of CDK using separate stacks, which is slower. One stack to create the bucket. After deploying that stack, use the Sumo Logic api to create or affirm prior creation of the Sumo Logic hosted collector and source, another CDK deploy to create the SNS topic and HTTP subscription.

I was just wondering if anyone knew of a better way to do this, perhaps some sort of deploy time hook that could be used.

3

There are 3 answers

0
moltar On

You could try using a Custom Resource SDK Call to trigger a lambda that does what you want.

https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_custom-resources.AwsSdkCall.html

0
Grzegorz Oledzki On

(I know this is not a perfect answer as it suggests to use another tool, yet I believe it fulfills the needs expressed in the question)

How about using Terraform?

sumologic_s3_source in Terraform is able to create the source at Sumo AND output its URL for other uses within Terraform - e.g. to set up AWS resources.

The docs on this even mention URL being one of the returned values:

url - The HTTP endpoint to use with SNS to notify Sumo Logic of new files.

Disclaimer: I am currently employed by Sumo Logic.

0
Sourabh Jain On

There are two ways(which I know of) in which you can automate the collection of AWS Application Load Balancer.

  1. Using CloudFormation
  • Sumo Logic have a template that creates the Collection process for AWS Application Load Balancer which is part of the AWS Observability Solution. You can fork the repository and can create your own CloudFormation template after removing resources you do not require.
  • Sumo Logic also have a Serverless Application which auto enable Access logging for existing and new (which are created after application installation) load balancer. Example template which uses the application.
  1. Using Terraform
  • As mentioned by Grzegorz, you can create a terraform script also.

Disclaimer: Currently employed by Sumo Logic.