Skip to content

Commit

Permalink
Contract tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan Grant committed Sep 30, 2022
1 parent 75ac673 commit 33f76c4
Show file tree
Hide file tree
Showing 132 changed files with 30,708 additions and 0 deletions.
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
### base ignores

# Distribution / packaging
build/
dist/

# Unit test / coverage reports
.cache
.hypothesis/
.pytest_cache/

# RPDK logs
rpdk.log*

# Node.js
node_modules/
coverage/

# contains credentials
sam-tests/

### Linux https://github.com/github/gitignore/blob/main/Global/Linux.gitignore

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### MacOS https://github.com/github/gitignore/blob/main/Global/macOS.gitignore

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Windows https://github.com/github/gitignore/blob/main/Global/Windows.gitignore


# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

# Intellij directory
.idea
1 change: 1 addition & 0 deletions Lacework-Agents-Token/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional = true
21 changes: 21 additions & 0 deletions Lacework-Agents-Token/.rpdk-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"artifact_type": "RESOURCE",
"typeName": "Lacework::Agents::Token",
"language": "typescript",
"runtime": "nodejs14.x",
"entrypoint": "dist/Lacework-Agents-Token/src/handlers.entrypoint",
"testEntrypoint": "dist/Lacework-Agents-Token/src/handlers.testEntrypoint",
"settings": {
"version": false,
"subparser_name": null,
"verbose": 0,
"force": false,
"type_name": null,
"artifact_type": null,
"endpoint_url": null,
"region": null,
"target_schemas": [],
"useDocker": false,
"protocolVersion": "2.0.0"
}
}
39 changes: 39 additions & 0 deletions Lacework-Agents-Token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Lacework::Agents::Token

Congratulations on starting development! Next steps:

1. Write the JSON schema describing your resource, [Lacework-agents-token.json](./Lacework-agents-token.json)
2. Implement your resource handlers in [handlers.ts](./Lacework-agents-token/handlers.ts)

> Don't modify [models.ts](./Lacework-agents-token/models.ts) by hand, any modifications will be overwritten when the `generate` or `package` commands are run.
Implement CloudFormation resource here. Each function must always return a ProgressEvent.

```typescript
const progress = ProgressEvent.builder<ProgressEvent<ResourceModel>>()

// Required
// Must be one of OperationStatus.InProgress, OperationStatus.Failed, OperationStatus.Success
.status(OperationStatus.InProgress)
// Required on SUCCESS (except for LIST where resourceModels is required)
// The current resource model after the operation; instance of ResourceModel class
.resourceModel(model)
.resourceModels(null)
// Required on FAILED
// Customer-facing message, displayed in e.g. CloudFormation stack events
.message('')
// Required on FAILED a HandlerErrorCode
.errorCode(HandlerErrorCode.InternalFailure)
// Optional
// Use to store any state between re-invocation via IN_PROGRESS
.callbackContext({})
// Required on IN_PROGRESS
// The number of seconds to delay before re-invocation
.callbackDelaySeconds(0)

.build()
```

While importing the [@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin) library, failures can be passed back to CloudFormation by either raising an exception from `exceptions`, or setting the ProgressEvent's `status` to `OperationStatus.Failed` and `errorCode` to one of `HandlerErrorCode`. There is a static helper function, `ProgressEvent.failed`, for this common case.

Keep in mind, during runtime all logs will be delivered to CloudWatch if you use the `log()` method from `LoggerProxy` class.
89 changes: 89 additions & 0 deletions Lacework-Agents-Token/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Lacework::Agents::Token

Lacework Agent Token schema. Once created a Lacework Agent token cannot be deleted so if you remove this resource Cloudformation will disable the token.

## Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

### JSON

<pre>
{
"Type" : "Lacework::Agents::Token",
"Properties" : {
"<a href="#tokenalias" title="TokenAlias">TokenAlias</a>" : <i>String</i>,
"<a href="#tokenenabled" title="TokenEnabled">TokenEnabled</a>" : <i>Double</i>,
"<a href="#props" title="Props">Props</a>" : <i><a href="props.md">Props</a></i>,
}
}
</pre>

### YAML

<pre>
Type: Lacework::Agents::Token
Properties:
<a href="#tokenalias" title="TokenAlias">TokenAlias</a>: <i>String</i>
<a href="#tokenenabled" title="TokenEnabled">TokenEnabled</a>: <i>Double</i>
<a href="#props" title="Props">Props</a>: <i><a href="props.md">Props</a></i>
</pre>

## Properties

#### TokenAlias

The token's alias such as Ops Agent. Aliases help communicate the intended purpose of a token and are effective when a value with a single intent appears in multiple places.

_Required_: Yes

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### TokenEnabled

The tokenEnabled property determines if an edit control is a "Text token" edit control. When the tokenEnabled property is set to 1, if the user enters a separator character or a carriage return (CR), a token is automatically added and the user can continue entering values in the control.

_Required_: Yes

_Type_: Double

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### Props

The access token's properties, including createdTime and description.



_Required_: No

_Type_: <a href="props.md">Props</a>

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

## Return Values

### Ref

When you pass the logical ID of this resource to the intrinsic `Ref` function, Ref returns the AccessToken.

### Fn::GetAtt

The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the `Fn::GetAtt` intrinsic function, see [Fn::GetAtt](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html).

#### AccessToken

The new agent access token.

#### CreatedTime

Returns the <code>CreatedTime</code> value.

#### Version

Returns the <code>Version</code> value.

46 changes: 46 additions & 0 deletions Lacework-Agents-Token/docs/props.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Lacework::Agents::Token Props

The access token's properties, including createdTime and description.



## Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

### JSON

<pre>
{
"<a href="#description" title="Description">Description</a>" : <i>String</i>,
"<a href="#os" title="Os">Os</a>" : <i>String</i>
}
</pre>

### YAML

<pre>
<a href="#description" title="Description">Description</a>: <i>String</i>
<a href="#os" title="Os">Os</a>: <i>String</i>
</pre>

## Properties

#### Description

_Required_: No

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

#### Os

The operating system

_Required_: No

_Type_: String

_Update requires_: [No interruption](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-no-interrupt)

12 changes: 12 additions & 0 deletions Lacework-Agents-Token/example_inputs/inputs_1_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"TPSCode": "...",
"Title": "...",
"CoverSheetIncluded": "...",
"DueDate": "...",
"ApprovalDate": "...",
"Memo": "...",
"SecondCopyOfMemo": "...",
"TestCode": "...",
"Authors": "...",
"Tags": "..."
}
12 changes: 12 additions & 0 deletions Lacework-Agents-Token/example_inputs/inputs_1_invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"TPSCode": "...",
"Title": "...",
"CoverSheetIncluded": "...",
"DueDate": "...",
"ApprovalDate": "...",
"Memo": "...",
"SecondCopyOfMemo": "...",
"TestCode": "...",
"Authors": "...",
"Tags": "..."
}
12 changes: 12 additions & 0 deletions Lacework-Agents-Token/example_inputs/inputs_1_update.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"TPSCode": "...",
"Title": "...",
"CoverSheetIncluded": "...",
"DueDate": "...",
"ApprovalDate": "...",
"Memo": "...",
"SecondCopyOfMemo": "...",
"TestCode": "...",
"Authors": "...",
"Tags": "..."
}
10 changes: 10 additions & 0 deletions Lacework-Agents-Token/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true,
collectCoverageFrom: [
"src/*.ts",
"!src/*.test.ts",
]
};
Loading

0 comments on commit 33f76c4

Please sign in to comment.