-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ContainerOnAWS/init
init
- Loading branch information
Showing
38 changed files
with
13,944 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.sonar/cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
- name: Cache Gradle packages | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: ${{ runner.os }}-gradle | ||
- name: Build and analyze | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: ./gradlew build sonarqube --info |
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,17 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { VpcStack } from '../lib/vpc-stack'; | ||
import { DEFAULT_STAGE } from '../../config'; | ||
|
||
const app = new cdk.App(); | ||
const env = { | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
region: process.env.CDK_DEFAULT_REGION | ||
}; | ||
const stage = app.node.tryGetContext('stage') || DEFAULT_STAGE; | ||
|
||
new VpcStack(app, `ecs-vpc-${stage}`, { | ||
env, | ||
description: 'VPC for AppRunner', | ||
terminationProtection: stage!==DEFAULT_STAGE | ||
}); |
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,32 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts bin/index.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | ||
"@aws-cdk/core:stackRelativeExports": true, | ||
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true, | ||
"@aws-cdk/aws-lambda:recognizeVersionProps": true, | ||
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
] | ||
} | ||
} |
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,38 @@ | ||
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib'; | ||
import { Construct } from 'constructs'; | ||
|
||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import * as ssm from 'aws-cdk-lib/aws-ssm'; | ||
|
||
import { SSM_PREFIX } from '../../config'; | ||
|
||
export class VpcStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const cidr = `10.100.0.0/16`; | ||
const vpc = new ec2.Vpc(this, 'Vpc', { | ||
maxAzs: 3, | ||
natGateways: 3, | ||
cidr, | ||
subnetConfiguration: [ | ||
{ | ||
cidrMask: 20, | ||
name: 'public', | ||
subnetType: ec2.SubnetType.PUBLIC, | ||
}, | ||
{ | ||
cidrMask: 20, | ||
name: 'private', | ||
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT, | ||
} | ||
] | ||
}); | ||
|
||
const parameter = new ssm.StringParameter(this, 'SSMVPCID', { parameterName: `${SSM_PREFIX}/vpc-id`, stringValue: vpc.vpcId }); | ||
new CfnOutput(this, 'VPC', { value: vpc.vpcId }); | ||
new CfnOutput(this, 'SSMParameter', { value: parameter.parameterName }); | ||
new CfnOutput(this, 'SSMParameterValue', { value: vpc.vpcId }); | ||
new CfnOutput(this, 'SSMURL', { value: `https://${this.region}.console.aws.amazon.com/systems-manager/parameters/` }); | ||
} | ||
} |
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,17 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { DEFAULT_STAGE } from '../../config'; | ||
import { EcsIamRoleStack } from '../lib/ecs-iam-role-stack'; | ||
|
||
const app = new cdk.App(); | ||
const env = { | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
region: process.env.CDK_DEFAULT_REGION | ||
}; | ||
const stage = app.node.tryGetContext('stage') || DEFAULT_STAGE; | ||
|
||
new EcsIamRoleStack(app, `apprunner-iam-role-${stage}`, { | ||
env, | ||
description: 'AppRunner IAM Role', | ||
terminationProtection: stage!==DEFAULT_STAGE | ||
}); |
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,32 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts bin/index.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | ||
"@aws-cdk/core:stackRelativeExports": true, | ||
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true, | ||
"@aws-cdk/aws-lambda:recognizeVersionProps": true, | ||
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
] | ||
} | ||
} |
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,36 @@ | ||
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib'; | ||
|
||
import * as ssm from 'aws-cdk-lib/aws-ssm'; | ||
import * as iam from 'aws-cdk-lib/aws-iam'; | ||
|
||
import { Construct } from 'constructs'; | ||
import { SSM_PREFIX } from '../../config'; | ||
|
||
/** | ||
* This stack is written to share IAM role among multiple-cluster | ||
* | ||
* https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html | ||
* | ||
* https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html | ||
* | ||
*/ | ||
export class EcsIamRoleStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const accessRole = new iam.Role(this, 'access-role', { | ||
roleName: `AppRunnerEcrAccessRole`, | ||
assumedBy: new iam.ServicePrincipal('build.apprunner.amazonaws.com'), | ||
managedPolicies: [ | ||
iam.ManagedPolicy.fromAwsManagedPolicyName( | ||
'service-role/AWSAppRunnerServicePolicyForECRAccess', | ||
), | ||
] | ||
}); | ||
|
||
const accessRoleParam = new ssm.StringParameter(this, 'ssm-access-role', { parameterName: `${SSM_PREFIX}/access-role-arn`, stringValue: accessRole.roleArn }); | ||
|
||
new CfnOutput(this, 'SSMTaskExecRoleParam', { value: accessRoleParam.parameterName }); | ||
new CfnOutput(this, 'SSMTaskExecRoleParamValue', { value: accessRoleParam.stringValue }); | ||
} | ||
} |
Oops, something went wrong.