-
Notifications
You must be signed in to change notification settings - Fork 5
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
introduce integration tests #109
Merged
Merged
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f23c74d
cdk init app --language typescript
shogo82148 ad2147d
add VPC
shogo82148 295bcb1
add bastion server
shogo82148 da3e266
configure ssm session manager
shogo82148 49b990c
introduce RDS
shogo82148 8f08c67
Add security group for RDS and allow ingress from bastion
shogo82148 afb6169
Grant read access to secret for bastion
shogo82148 5e78187
Add IAM authentication and grant connect permission to RDS cluster
shogo82148 43de0ff
connect to the test database
shogo82148 ce2555d
initialize the user for testing
shogo82148 1b6a328
add integrated test for Apply
shogo82148 3b45836
Add port number to MySQL address in config
shogo82148 5348adf
ensures that addr has a port.
shogo82148 9e0ac27
configure the region
shogo82148 fe44fe8
add test for the connector
shogo82148 f4e5b95
add test for rdsmysql command
shogo82148 a4c3dd2
Add port configuration to test case
shogo82148 a5c3018
add integrated test for v2
shogo82148 1afa59f
fix the import path
shogo82148 7ccf2aa
fix the import path
shogo82148 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.js | ||
!jest.config.js | ||
*.d.ts | ||
node_modules | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
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,14 @@ | ||
# Welcome to your CDK TypeScript project | ||
|
||
This is a blank project for CDK development with TypeScript. | ||
|
||
The `cdk.json` file tells the CDK Toolkit how to execute your app. | ||
|
||
## Useful commands | ||
|
||
* `npm run build` compile typescript to js | ||
* `npm run watch` watch for changes and compile | ||
* `npm run test` perform the jest unit tests | ||
* `cdk deploy` deploy this stack to your default AWS account/region | ||
* `cdk diff` compare deployed stack with current state | ||
* `cdk synth` emits the synthesized CloudFormation template | ||
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,9 @@ | ||
#!/usr/bin/env node | ||
import "source-map-support/register"; | ||
import * as cdk from "aws-cdk-lib"; | ||
import { IntegrationStack } from "../lib/integration-stack"; | ||
|
||
const app = new cdk.App(); | ||
new IntegrationStack(app, "IntegrationStack", { | ||
env: { account: "339712736426", region: "ap-northeast-1" }, | ||
shogo82148 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); |
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,9 @@ | ||
{ | ||
"availability-zones:account=339712736426:region=ap-northeast-1": [ | ||
"ap-northeast-1a", | ||
"ap-northeast-1c", | ||
"ap-northeast-1d" | ||
], | ||
"ssm:account=339712736426:parameterName=/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64:region=ap-northeast-1": "ami-039e8f15ccb15368a", | ||
"ssm:account=339712736426:parameterName=/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-arm64:region=ap-northeast-1": "ami-0f5c39b95599ade7f" | ||
} |
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,53 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts bin/integration.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-lambda:recognizeLayerVersion": true, | ||
"@aws-cdk/core:checkSecretUsage": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
], | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, | ||
"@aws-cdk/aws-iam:minimizePolicies": true, | ||
"@aws-cdk/core:validateSnapshotRemovalPolicy": true, | ||
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, | ||
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, | ||
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, | ||
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true, | ||
"@aws-cdk/core:enablePartitionLiterals": true, | ||
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, | ||
"@aws-cdk/aws-iam:standardizedServicePrincipals": true, | ||
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true, | ||
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true, | ||
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true, | ||
"@aws-cdk/aws-route53-patters:useCertificate": true, | ||
"@aws-cdk/customresources:installLatestAwsSdkDefault": false, | ||
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true, | ||
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true, | ||
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true, | ||
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true, | ||
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true, | ||
"@aws-cdk/aws-redshift:columnId": true, | ||
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true, | ||
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true, | ||
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true | ||
} | ||
} |
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,8 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
roots: ['<rootDir>/test'], | ||
testMatch: ['**/*.test.ts'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
} | ||
}; |
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,46 @@ | ||
import * as cdk from "aws-cdk-lib"; | ||
import { Construct } from "constructs"; | ||
import * as ec2 from "aws-cdk-lib/aws-ec2"; | ||
import * as rds from "aws-cdk-lib/aws-rds"; | ||
|
||
export class IntegrationStack extends cdk.Stack { | ||
constructor(scope: Construct, id: string, props?: cdk.StackProps) { | ||
super(scope, id, props); | ||
|
||
// VPC | ||
const vpc = new ec2.Vpc(this, "MyVpc", {}); | ||
|
||
// Bastion EC2 Instance | ||
const bastionSG = new ec2.SecurityGroup(this, "BastionSG", { | ||
vpc, | ||
}); | ||
const bastion = new ec2.BastionHostLinux(this, "Bastion", { | ||
vpc, | ||
instanceType: ec2.InstanceType.of( | ||
ec2.InstanceClass.T4G, | ||
ec2.InstanceSize.MICRO | ||
), | ||
machineImage: new ec2.AmazonLinux2023ImageSsmParameter({ | ||
cpuType: ec2.AmazonLinuxCpuType.ARM_64, | ||
}), | ||
securityGroup: bastionSG, | ||
}); | ||
|
||
// Relational Database Service | ||
const rdsSG = new ec2.SecurityGroup(this, "RDSSG", { | ||
vpc, | ||
}); | ||
rdsSG.addIngressRule(bastionSG, ec2.Port.tcp(3306)); | ||
const cluster = new rds.DatabaseCluster(this, "Database", { | ||
engine: rds.DatabaseClusterEngine.auroraMysql({ | ||
version: rds.AuroraMysqlEngineVersion.VER_3_05_2, | ||
}), | ||
writer: rds.ClusterInstance.serverlessV2("writer"), | ||
vpc, | ||
securityGroups: [rdsSG], | ||
iamAuthentication: true, | ||
}); | ||
cluster.secret?.grantRead(bastion); | ||
cluster.grantConnect(bastion, "rdsmysql"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The README file effectively introduces the project and provides a concise list of useful commands for managing the CDK TypeScript project. However, there are minor formatting issues with extra whitespaces before some of the commands. Additionally, the file types mentioned (e.g., "js") should be capitalized for consistency.
Consider removing extra whitespaces for a cleaner format and capitalizing file types for consistency.
Committable suggestion