-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(route53resolver-alpha): fetch managed domain list id using custom resource #27085
Changes from 27 commits
0b673b6
3250edd
26cd0b5
e65f4b2
54a1abd
ae537f8
6682ddb
5dea4e2
d4ebb8e
d37d7cf
2abdbce
c175808
09cce5f
2c78874
ffaa2d1
fddea51
37fb679
cb6771a
ceeb855
894829d
3a5f414
8ff27b0
88cb78d
fcd82d6
861c0e9
d5538a5
ea4b833
597ea16
16399ac
31d7f53
481b312
9d296b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,82 @@ | ||||||||||||
import * as path from 'path'; | ||||||||||||
import { Resource, CustomResourceProvider, CustomResource, CustomResourceProviderRuntime } from 'aws-cdk-lib/core'; | ||||||||||||
import { Construct } from 'constructs'; | ||||||||||||
import { IFirewallDomainList } from './firewall-domain-list'; | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Properties for a Firewall Managed Domain List | ||||||||||||
*/ | ||||||||||||
export interface FirewallManagedDomainListProps { | ||||||||||||
/** | ||||||||||||
* The managed domain list | ||||||||||||
*/ | ||||||||||||
readonly managedDomainList: ManagedDomain; | ||||||||||||
} | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* A Firewall Managed Domain List | ||||||||||||
* | ||||||||||||
* @resource AWS::CloudFormation::CustomResource | ||||||||||||
*/ | ||||||||||||
export class FirewallManagedDomainList extends Resource implements IFirewallDomainList { | ||||||||||||
public readonly firewallDomainListId: string; | ||||||||||||
|
||||||||||||
constructor(scope: Construct, id: string, props: FirewallManagedDomainListProps) { | ||||||||||||
super(scope, id); | ||||||||||||
|
||||||||||||
const GET_MANAGED_DOMAIN_LIST_TYPE = 'Custom::Route53ResolverManagedDomainList'; | ||||||||||||
const provider = CustomResourceProvider.getOrCreateProvider(this, GET_MANAGED_DOMAIN_LIST_TYPE, { | ||||||||||||
codeDirectory: path.join(__dirname, '..', '..', | ||||||||||||
'custom-resource-handlers', 'dist', 'aws-route53resolver-alpha', 'managed-domain-list-handler'), | ||||||||||||
useCfnResponseWrapper: false, | ||||||||||||
runtime: CustomResourceProviderRuntime.NODEJS_18_X, | ||||||||||||
description: 'Lambda function for getting route 53 resolver managed domain list ID', | ||||||||||||
policyStatements: [{ | ||||||||||||
Effect: 'Allow', | ||||||||||||
Action: ['route53resolver:ListFirewallDomainLists'], | ||||||||||||
Resource: '*', | ||||||||||||
}], | ||||||||||||
}); | ||||||||||||
|
||||||||||||
const result = new CustomResource(this, 'GetDomainListCustomResource', { | ||||||||||||
resourceType: GET_MANAGED_DOMAIN_LIST_TYPE, | ||||||||||||
serviceToken: provider.serviceToken, | ||||||||||||
properties: { | ||||||||||||
DomainListName: props.managedDomainList, | ||||||||||||
}, | ||||||||||||
}); | ||||||||||||
|
||||||||||||
this.firewallDomainListId = result.getAttString('DomainListId'); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
} | ||||||||||||
} | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Managed Domain Lists | ||||||||||||
* | ||||||||||||
* @see https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-dns-firewall-managed-domain-lists.html | ||||||||||||
*/ | ||||||||||||
export enum ManagedDomain { | ||||||||||||
/** | ||||||||||||
* Domains associated with multiple DNS threat categories including malware, ransomware, botnet, spyware, | ||||||||||||
* and DNS tunneling to help block multiple types of threats. | ||||||||||||
* Includes the `AmazonGuardDutyThreatList.` | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
*/ | ||||||||||||
AGGREGATE_THREAT_LIST = 'AWSManagedDomainsAggregateThreatList', | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Domains associated with Amazon GuardDuty DNS security findings. | ||||||||||||
* The domains are sourced from the GuardDuty's threat intelligence systems only, | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
* and do not contain domains sourced from external third-party sources. | ||||||||||||
*/ | ||||||||||||
AMAZON_GUARDDUTY_THREAT_LIST = 'AWSManagedDomainsAmazonGuardDutyThreatList', | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Domains associated with controlling networks of computers that are infected with spamming malware. | ||||||||||||
*/ | ||||||||||||
BOTNET_COMMANDAND_CONTROL = 'AWSManagedDomainsBotnetCommandandControl', | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* Domains associated with sending malware, hosting malware, or distributing malware. | ||||||||||||
*/ | ||||||||||||
MALWARE_DOMAIN_LIST = 'AWSManagedDomainsMalwareDomainList', | ||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||
import { Template } from 'aws-cdk-lib/assertions'; | ||||||
import { Stack } from 'aws-cdk-lib'; | ||||||
import { FirewallManagedDomainList, ManagedDomain } from '../lib'; | ||||||
|
||||||
let stack: Stack; | ||||||
beforeEach(() => { | ||||||
stack = new Stack(); | ||||||
}); | ||||||
|
||||||
test('importing managed domain list creates custom resource', () => { | ||||||
// WHEN | ||||||
new FirewallManagedDomainList(stack, 'List', { | ||||||
managedDomainList: ManagedDomain.MALWARE_DOMAIN_LIST, | ||||||
}); | ||||||
|
||||||
// THEN | ||||||
Template.fromStack(stack).hasResourceProperties('Custom::Route53ResolverManagedDomainList', { | ||||||
DomainListName: 'AWSManagedDomainsMalwareDomainList', | ||||||
}); | ||||||
Template.fromStack(stack).hasResourceProperties('AWS::IAM::Role', { | ||||||
ManagedPolicyArns: [ | ||||||
{ | ||||||
'Fn::Sub': 'arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole', | ||||||
}, | ||||||
], | ||||||
Policies: [ | ||||||
{ | ||||||
PolicyName: 'Inline', | ||||||
PolicyDocument: { | ||||||
Version: '2012-10-17', | ||||||
Statement: [ | ||||||
{ | ||||||
Effect: 'Allow', | ||||||
Action: ['route53resolver:ListFirewallDomainLists'], | ||||||
Resource: '*', | ||||||
}, | ||||||
], | ||||||
}, | ||||||
}, | ||||||
], | ||||||
}); | ||||||
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {}); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
More appropriate assertion. |
||||||
}); | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming.