-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {App} from "aws-cdk-lib"; | ||
import {VpcStack} from "../lib/stacks/vpc"; | ||
import {Template} from "aws-cdk-lib/assertions"; | ||
import {OpenSearchHealthRoute53} from "../lib/stacks/route53"; | ||
import Project from "../lib/enums/project"; | ||
|
||
test('HostedZone Stack Test', () => { | ||
const app = new App(); | ||
const hostedZoneStack = new OpenSearchHealthRoute53(app, 'Test-OpenSearchMetrics-HostedZone', { | ||
hostedZone: Project.METRICS_HOSTED_ZONE, | ||
appName: "OpenSearchMetrics" | ||
}); | ||
const hostedZoneStackTemplate = Template.fromStack(hostedZoneStack); | ||
hostedZoneStackTemplate.resourceCountIs('AWS::Route53::HostedZone', 1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {App} from "aws-cdk-lib"; | ||
import {VpcStack} from "../lib/stacks/vpc"; | ||
import {Template} from "aws-cdk-lib/assertions"; | ||
import {OpenSearchMetricsNginxReadonly} from "../lib/stacks/opensearchNginxProxyReadonly"; | ||
import Project from "../lib/enums/project"; | ||
import {OpenSearchDomainStack} from "../lib/stacks/opensearch"; | ||
import {ArnPrincipal} from "aws-cdk-lib/aws-iam"; | ||
import {OpenSearchHealthRoute53} from "../lib/stacks/route53"; | ||
|
||
test('Nginx Stack Test', () => { | ||
const app = new App(); | ||
const vpcStack = new VpcStack(app, "OpenSearchHealth-VPC", {}); | ||
const openSearchDomainStack = new OpenSearchDomainStack(app, "OpenSearchHealth-OpenSearch", { | ||
region: Project.REGION, | ||
account: Project.AWS_ACCOUNT, | ||
vpcStack: vpcStack, | ||
enableNginxCognito: true, | ||
jenkinsAccess: { | ||
jenkinsAccountRoles: [ | ||
new ArnPrincipal(Project.JENKINS_MASTER_ROLE), | ||
new ArnPrincipal(Project.JENKINS_AGENT_ROLE) | ||
] | ||
} | ||
}); | ||
const metricsHostedZone = new OpenSearchHealthRoute53(app, "OpenSearchMetrics-HostedZone", { | ||
hostedZone: Project.METRICS_HOSTED_ZONE, | ||
appName: "OpenSearchMetrics" | ||
}); | ||
const stack = new OpenSearchMetricsNginxReadonly(app, 'Test-OpenSearchMetricsNginxReadonly', { | ||
region: Project.REGION, | ||
account: Project.AWS_ACCOUNT, | ||
vpc: vpcStack.vpc, | ||
securityGroup: vpcStack.securityGroup, | ||
opensearchDashboardUrlProps: { | ||
opensearchDashboardVpcUrl: openSearchDomainStack.domain.domainEndpoint, | ||
openSearchDomainName: openSearchDomainStack.domain.domainName | ||
}, | ||
albProps: { | ||
hostedZone: metricsHostedZone, | ||
certificateArn: metricsHostedZone.certificateArn, | ||
}, | ||
}); | ||
const template = Template.fromStack(stack); | ||
template.resourceCountIs('AWS::EC2::SecurityGroup', 2); | ||
template.hasResourceProperties('AWS::EC2::SecurityGroup', { | ||
"SecurityGroupEgress": [ | ||
{ | ||
"CidrIp": "0.0.0.0/0", | ||
"Description": "Allow all outbound traffic by default", | ||
"IpProtocol": "-1" | ||
} | ||
] | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {App} from "aws-cdk-lib"; | ||
import {Template} from "aws-cdk-lib/assertions"; | ||
import {OpenSearchMetricsWorkflowStack} from "../lib/stacks/metricsWorkflow"; | ||
import Project from "../lib/enums/project"; | ||
import {OpenSearchDomainStack} from "../lib/stacks/opensearch"; | ||
import {VpcStack} from "../lib/stacks/vpc"; | ||
import {ArnPrincipal} from "aws-cdk-lib/aws-iam"; | ||
|
||
test('Workflow Stack Test', () => { | ||
const app = new App(); | ||
const vpcStack = new VpcStack(app, 'Test-OpenSearchHealth-VPC', {}) | ||
const OpenSearchMetricsWorkflow = new OpenSearchMetricsWorkflowStack(app, 'Test-OpenSearchMetrics-Workflow', { | ||
opensearchDomainStack: new OpenSearchDomainStack(app, 'Test-OpenSearchHealth-OpenSearch', { | ||
region: "us-east-1", | ||
account: "test-account", | ||
vpcStack: vpcStack, | ||
enableNginxCognito: true, | ||
jenkinsAccess: { | ||
jenkinsAccountRoles: [ | ||
new ArnPrincipal(Project.JENKINS_MASTER_ROLE), | ||
new ArnPrincipal(Project.JENKINS_AGENT_ROLE) | ||
] | ||
} | ||
}), | ||
vpcStack: vpcStack, | ||
lambdaPackage: Project.LAMBDA_PACKAGE | ||
}); | ||
const template = Template.fromStack(OpenSearchMetricsWorkflow); | ||
template.resourceCountIs('AWS::Lambda::Function', 1); | ||
template.resourceCountIs('AWS::IAM::Role', 2); | ||
}); |