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

(aws-cdk/aws-cloudtrail): Support DynamoDB as a DataResourceType in CloudTrail #14886

Open
2 tasks
Parker-Ledoux opened this issue May 27, 2021 · 12 comments
Open
2 tasks
Labels
@aws-cdk/aws-cloudtrail Related to AWS CloudTrail effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p3 service-api This issue is due to a problem in a service API

Comments

@Parker-Ledoux
Copy link

About two months ago, AWS CloudTrail officially announced support for audit logging and monitoring of DynamoDb. More information about that here.
Today the aws-cdk only supports S3 and Lambda as data resource types and it would be super useful to be able to use cdk to construct our CloudTrail trails for DynamoDB as well.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@Parker-Ledoux Parker-Ledoux added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 27, 2021
@github-actions github-actions bot added @aws-cdk/aws-cloudtrail Related to AWS CloudTrail @aws-cdk/aws-dynamodb Related to Amazon DynamoDB labels May 27, 2021
@peterwoodworth peterwoodworth added feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. p2 effort/small Small work item – less than a day of effort and removed @aws-cdk/aws-dynamodb Related to Amazon DynamoDB needs-triage This issue or PR still needs to be triaged. labels Jul 2, 2021
@TheRealAmazonKendra TheRealAmazonKendra added the blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. label Aug 5, 2022
@TheRealAmazonKendra
Copy link
Contributor

This is currently blocked by another issue. We will update here when it is unblocked and reopen @peterwoodworth's pr.

@aws aws deleted a comment from peterwoodworth Aug 5, 2022
@cowsandmilk
Copy link

Is there an update on this?

@issakr
Copy link

issakr commented Jan 21, 2023

any update please

@scott-korin
Copy link

Any update?

@lurumad
Copy link

lurumad commented Apr 19, 2023

Any update on this?

Is there any workaround at that moment?

@peterwoodworth
Copy link
Contributor

We're still blocked on implementing l2 support. You'll need to use L1s, or implement escape hatches to use this feature in the meantime

@peterwoodworth peterwoodworth added service-api This issue is due to a problem in a service API and removed feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. labels May 11, 2023
@holomekc
Copy link

An example in Java via escape hatches.

final List<String> tableArns = dbStack.getTableArns();

final CfnTrail cfnTrail = (CfnTrail) trail.getNode().getDefaultChild();

final CfnTrail.DataResourceProperty dataResource =
        CfnTrail.DataResourceProperty.builder().type("AWS::DynamoDB::Table").values(tableArns).build();
final CfnTrail.EventSelectorProperty selector =
        CfnTrail.EventSelectorProperty.builder().dataResources(List.of(dataResource))
                .includeManagementEvents(false).readWriteType("All").build();

cfnTrail.setEventSelectors(List.of(selector));

Other languages regarding escape hatches here: https://docs.aws.amazon.com/cdk/v2/guide/cfn_layer.html

@eiva
Copy link

eiva commented Nov 10, 2023

Any progress on this?

@matthiasbruns
Copy link

matthiasbruns commented Nov 17, 2023

same here - tried to setup cloudtrail with dynamo, but still no support

	trail := awscloudtrail.NewTrail(
		scope,
		jsii.String(fmt.Sprintf(trailName)),
		&awscloudtrail.TrailProps{
			TrailName:                  jsii.String(trailName),
			Bucket:                     trailBucket,
			IsMultiRegionTrail:         jsii.Bool(true),
			IncludeGlobalServiceEvents: jsii.Bool(true),
		},
	)

	trailDataSource := &awscloudtrail.CfnTrail_DataResourceProperty{
		Type: jsii.String("AWS::DynamoDB::Table"),
		Values: &[]*string{
			props.DB.TableArn(),
		},
	}

	trailDataSelector := awscloudtrail.CfnTrail_EventSelectorProperty{
		DataResources:           trailDataSource,
		IncludeManagementEvents: jsii.Bool(false),
		ReadWriteType:           jsii.String(string(awscloudtrail.ReadWriteType_WRITE_ONLY)),
	}

	trail.Node().DefaultChild().(awscloudtrail.CfnTrail).SetEventSelectors([]interface{}{trailDataSelector})

the version in Go, in the meantime

@gshpychka
Copy link
Contributor

@peterwoodworth could you clarify what's blocking you? Seems straightforward to implement on the surface

@peterwoodworth
Copy link
Contributor

Hey Glib, I'm not sure we can get into the specifics here, however I am still keeping tabs on this and will push to merge this feature once we're able to.

Just a heads up, I'm not with the CDK team anymore (however am still with Amazon). It was very pleasant working with you here 🙂

@dparish
Copy link

dparish commented May 16, 2024

In case someone else needs this:

Here is how I was able to get this to work with Typescript and the CDK. Thank you to @holomekc for the inspiration on how to do this.

    const dynamoTrail = new Trail(this, 'some-trail', {
      trailName: 'some-trail',
    });

    const cfnTrail = dynamoTrail.node.defaultChild as CfnTrail;
    cfnTrail.eventSelectors = [
      {
        dataResources: [
          {
            type: 'AWS::DynamoDB::Table',
            values: [mytable.tableArn],
          },
        ],
        includeManagementEvents: false,
        readWriteType: 'All',
      },
    ];

@pahud pahud added p3 and removed p2 labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudtrail Related to AWS CloudTrail effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p3 service-api This issue is due to a problem in a service API
Projects
None yet
Development

Successfully merging a pull request may close this issue.