Skip to content

Commit 95720e8

Browse files
Make certain request fields optional to unblock contract testing (#25)
* make optional request fields * fix readme ci icon * fix proxy dependency * format properly * make response endpoint optional * put back request context
1 parent e540a53 commit 95720e8

17 files changed

+226
-144
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ We're excited to share our progress with adding new languages to the CloudFormat
77
88
## AWS CloudFormation Resource Provider TypeScript Plugin
99

10-
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/eduardomourar/cloudformation-cli-typescript-plugin/ci)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/actions?query=workflow%3Aci) [![Codecov](https://img.shields.io/codecov/c/gh/eduardomourar/cloudformation-cli-typescript-plugin)](https://codecov.io/gh/eduardomourar/cloudformation-cli-typescript-plugin) [![GitHub release](https://img.shields.io/github/v/release/eduardomourar/cloudformation-cli-typescript-plugin?include_prereleases)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/releases) [![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/eduardomourar/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)
10+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/eduardomourar/cloudformation-cli-typescript-plugin/ci/master)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/actions?query=branch%3Amaster+workflow%3Aci) [![Codecov](https://img.shields.io/codecov/c/gh/eduardomourar/cloudformation-cli-typescript-plugin)](https://codecov.io/gh/eduardomourar/cloudformation-cli-typescript-plugin) [![GitHub release](https://img.shields.io/github/v/release/eduardomourar/cloudformation-cli-typescript-plugin?include_prereleases)](https://github.com/eduardomourar/cloudformation-cli-typescript-plugin/releases) [![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/eduardomourar/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)
1111

1212
The CloudFormation CLI (cfn) allows you to author your own resource providers that can be used by CloudFormation.
1313

package-lock.json

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"typescript": "^3.7.0"
6363
},
6464
"optionalDependencies": {
65-
"aws-sdk": "~2.631.0"
65+
"aws-sdk": "~2.712.0"
6666
},
6767
"prettier": {
6868
"parser": "typescript",

python/rpdk/typescript/templates/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '{{lib_name}}';
1313
import { ResourceModel } from './models';
1414

15-
// Use this logger to forward log messages to CloudWatch Logs.
15+
// Use this logger to forward messages to CloudWatch Logs.
1616
const LOGGER = console;
1717

1818
interface CallbackContext extends Record<string, any> {}

python/rpdk/typescript/templates/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "{{ name }}",
33
"version": "0.1.0",
44
"description": "{{ description }}",
5+
"private": true,
56
"main": "dist/handlers.js",
67
"files": [
78
"dist"

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def find_version(*file_paths):
3737
include_package_data=True,
3838
zip_safe=True,
3939
python_requires=">=3.6",
40-
install_requires=["cloudformation-cli>=0.1,<0.2", "aws-lambda-builders>=0.8,<0.9"],
40+
install_requires=[
41+
"cloudformation-cli>=0.1.10,<0.2",
42+
"aws-lambda-builders>=0.8,<0.9",
43+
],
4144
entry_points={
4245
"rpdk.v1.languages": [
4346
"typescript = rpdk.typescript.codegen:TypescriptLanguagePlugin",

src/interface.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,16 @@ export class TestEvent extends BaseDto {
206206
}
207207

208208
export class RequestData<T = Dict> extends BaseDto {
209-
@Expose() callerCredentials?: Credentials;
210-
@Expose() providerCredentials?: Credentials;
211-
@Expose() providerLogGroupName: LogGroupName;
212-
@Expose() logicalResourceId: LogicalResourceId;
213209
@Expose() resourceProperties: T;
214-
@Expose() previousResourceProperties?: T;
210+
@Expose() providerLogGroupName?: LogGroupName;
211+
@Expose() logicalResourceId?: LogicalResourceId;
215212
@Expose() systemTags?: Dict<string>;
216213
@Expose() stackTags?: Dict<string>;
214+
// platform credentials aren't really optional, but this is used to
215+
// zero them out to prevent e.g. accidental logging
216+
@Expose() callerCredentials?: Credentials;
217+
@Expose() providerCredentials?: Credentials;
218+
@Expose() previousResourceProperties?: T;
217219
@Expose() previousStackTags?: Dict<string>;
218220
}
219221

@@ -222,14 +224,14 @@ export class HandlerRequest<ResourceT = Dict, CallbackT = Dict> extends BaseDto
222224
@Expose() awsAccountId: string;
223225
@Expose() bearerToken: string;
224226
@Expose() region: string;
225-
@Expose() responseEndpoint: string;
226-
@Expose() resourceType: string;
227-
@Expose() resourceTypeVersion: string;
228227
@Expose() requestData: RequestData<ResourceT>;
229-
@Expose() stackId: string;
228+
@Expose() responseEndpoint?: string;
229+
@Expose() stackId?: string;
230+
@Expose() resourceType?: string;
231+
@Expose() resourceTypeVersion?: string;
230232
@Expose() callbackContext?: CallbackT;
231233
@Expose() nextToken?: NextToken;
232-
@Expose() requestContext: RequestContext<CallbackT>;
234+
@Expose() requestContext?: RequestContext<CallbackT>;
233235
}
234236

235237
export class BaseResourceHandlerRequest<T extends BaseModel> extends BaseDto {

src/log-delivery.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ export class ProviderLogHandler {
148148
'CloudWatchLogs'
149149
) as CloudWatchLogs;
150150
} else {
151-
// Filter provider messages from platform.
152-
const provider: string = request.resourceType
153-
.replace(/::/g, '_')
154-
.toLowerCase();
155151
logHandler = ProviderLogHandler.instance = new ProviderLogHandler({
156152
accountId: request.awsAccountId,
157153
groupName: logGroup,

0 commit comments

Comments
 (0)