Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
.
  • Loading branch information
engel80 authored Jul 28, 2022
1 parent 30b4971 commit 08998c5
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 100 deletions.
36 changes: 0 additions & 36 deletions 1.txt

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Table of Contents
## Prerequisites

```bash
npm install -g aws-cdk@2.25.0
npm install -g aws-cdk@2.33.0

# install packages in the root folder
npm install
Expand Down Expand Up @@ -121,6 +121,7 @@ SSM parameter:
│   └── apigw.png
└── tsconfig.json
```

## Reference

* [CloudFormation quotas](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html)
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ sonarqube {
property "sonar.projectKey", "cdk-lambda-apigateway"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "."
property "sonar.exclusions", "**/node_modules/**"
property "sonar.exclusions", "**/node_modules/**, **/cdk.out/**"
property "sonar.cpd.exclusions", "**/*index.ts"
property "sonar.issue.ignore.multicriteria", "e1"
property "sonar.issue.ignore.multicriteria.e1.ruleKey", "typescript:S1848"
property "sonar.issue.ignore.multicriteria.e1.resourceKey", "**/*.ts"
property "sonar.host.url", "http://127.0.0.1:9000"
property "sonar.links.ci", "https://github.com/engel80/cdk-lambda-apigateway"
property "sonar.log.level", "DEBUG"
}
Expand Down
11 changes: 3 additions & 8 deletions device-api/lib/device-api-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Stack } from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as ssm from 'aws-cdk-lib/aws-ssm';
Expand All @@ -15,8 +15,6 @@ export class DeviceApiStack extends Stack {
constructor(scope: Construct, id: string, props: StackCommonProps) {
super(scope, id, props);

const stage = props.stage;

const restApiId = ssm.StringParameter.valueForStringParameter(this, `${SSM_PREFIX}/rest-api-id`);
const rootResourceId = ssm.StringParameter.valueForStringParameter(this, `${SSM_PREFIX}/root-resource-id`);
const rootApi = apigateway.RestApi.fromRestApiAttributes(this, "root-api", { restApiId, rootResourceId });
Expand All @@ -28,10 +26,7 @@ export class DeviceApiStack extends Stack {
});

const servicea = rootApi.root.addResource('device');
const v1 = servicea.addResource('v1');
const v1DeviceId = v1.addResource('{deviceid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));

const v2 = servicea.addResource('v2');
const v2DeviceId = v2.addResource('{deviceid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
servicea.addResource('v1').addResource('{deviceid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
servicea.addResource('v2').addResource('{deviceid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"typescript": "~3.9.7"
},
"dependencies": {
"aws-cdk-lib": "2.15.0",
"aws-cdk-lib": "2.33.0",
"constructs": "^10.0.0"
}
}
12 changes: 5 additions & 7 deletions product-api/lib/product-api-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Stack } from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as ssm from 'aws-cdk-lib/aws-ssm';
Expand All @@ -15,8 +15,6 @@ export class ProductApiStack extends Stack {
constructor(scope: Construct, id: string, props: StackCommonProps) {
super(scope, id, props);

const stage = props.stage;

const restApiId = ssm.StringParameter.valueForStringParameter(this, `${SSM_PREFIX}/rest-api-id`);
const rootResourceId = ssm.StringParameter.valueForStringParameter(this, `${SSM_PREFIX}/root-resource-id`);
const rootApi = apigateway.RestApi.fromRestApiAttributes(this, "root-api", { restApiId, rootResourceId });
Expand All @@ -29,11 +27,11 @@ export class ProductApiStack extends Stack {

const servicea = rootApi.root.addResource('product');
const v1 = servicea.addResource('v1');
const v1Categories = v1.addResource('categories').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
const v1CcategoryId = v1.addResource('{categoryid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
v1.addResource('categories').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
v1.addResource('{categoryid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));

const v2 = servicea.addResource('v2');
const v2Categories = v2.addResource('categories').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
const v2CcategoryId = v2.addResource('{categoryid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
v2.addResource('categories').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
v2.addResource('{categoryid}').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
}
}
8 changes: 7 additions & 1 deletion root-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ archivesBaseName = 'cdk-lambda-apigateway'
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5")
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513")
}
}

Expand All @@ -19,6 +22,9 @@ sonarqube {
property "sonar.sources", "."
property "sonar.exclusions", "**/node_modules/**"
property "sonar.cpd.exclusions", "**/*index.ts"
property "sonar.issue.ignore.multicriteria", "e1"
property "sonar.issue.ignore.multicriteria.e1.ruleKey", "typescript:S1848"
property "sonar.issue.ignore.multicriteria.e1.resourceKey", "**/*.ts"
property "sonar.links.ci", "https://github.com/engel80/cdk-lambda-apigateway"
property "sonar.log.level", "DEBUG"
}
Expand Down
13 changes: 3 additions & 10 deletions root-api/lib/root-api-stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Stack } from 'aws-cdk-lib';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
import * as ssm from 'aws-cdk-lib/aws-ssm';
Expand All @@ -14,13 +14,7 @@ export class RootApiStack extends Stack {

const stage = props.stage;

const lambda1 = new lambda.Function(this, 'lambda1', {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromAsset('../app'),
handler: 'hello.handler'
});

const lambda2 = new lambda.Function(this, 'lambda2', {
const lambdaPing = new lambda.Function(this, 'lambd-aping', {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromAsset('../app'),
handler: 'hello.handler'
Expand All @@ -32,8 +26,7 @@ export class RootApiStack extends Stack {
}
});
const servicea = api.root.addResource('dummy-for-import');
const v1 = servicea.addResource('v1');
const v1Ping = v1.addResource('ping').addMethod('GET', new apigateway.LambdaIntegration(lambda1, { proxy: true }));
servicea.addResource('v1').addResource('ping').addMethod('GET', new apigateway.LambdaIntegration(lambdaPing, { proxy: true }));

new ssm.StringParameter(this, 'api-id', { parameterName: `${SSM_PREFIX}/rest-api-id`, stringValue: api.restApiId });
new ssm.StringParameter(this, 'root-resource-id', { parameterName: `${SSM_PREFIX}/root-resource-id`, stringValue: api.root.resourceId });
Expand Down
1 change: 0 additions & 1 deletion test/apigw-test.test.d.ts

This file was deleted.

17 changes: 0 additions & 17 deletions test/apigw-test.test.js

This file was deleted.

17 changes: 0 additions & 17 deletions test/apigw-test.test.ts

This file was deleted.

0 comments on commit 08998c5

Please sign in to comment.