Skip to content

Commit 76e565e

Browse files
authored
Merge pull request #11 from sliedig/develop
chore: Updated README files and bumped dependencies
2 parents ca02eea + 9d40743 commit 76e565e

File tree

16 files changed

+166
-455
lines changed

16 files changed

+166
-455
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- markdownlint-disable MD041 MD043 -->
21
**Issue number:**
32

43
## Summary
@@ -20,19 +19,6 @@ Please leave checklist items unchecked if they do not apply to your change.
2019
* [ ] Changes are documented
2120
* [ ] PR title follows [conventional commit semantics](https://github.com/aws-samples/aws-serverless-developer-experience-workshop-dotnet/blob/develop/.github/semantic.yml)
2221

23-
24-
<details>
25-
<summary>Is this a breaking change?</summary>
26-
27-
**RFC issue number**:
28-
29-
Checklist:
30-
31-
* [ ] Migration process documented
32-
* [ ] Implement warnings (if it can live side by side)
33-
34-
</details>
35-
3622
## Acknowledgment
3723

3824
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.github/auto_assign.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ reviewers:
1212
# Set 0 to add all the reviewers (default: 0)
1313
numberOfReviewers: 1
1414

15+
# A list of assignees, overrides reviewers if set
16+
# assignees:
17+
- @aws-samples/aws-serverless-developer-experience-workshop-dotnet
1518

1619
# A number of assignees to add to the pull request
1720
# Set to 0 to add all of the assignees.
1821
# Uses numberOfReviewers if unset.
19-
# numberOfAssignees: 2
22+
numberOfAssignees: 0
2023

2124
# A list of keywords to be skipped the process that add reviewers if pull requests include it
2225
# skipKeywords:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const {
2+
PR_ACTION,
3+
PR_AUTHOR,
4+
PR_BODY,
5+
PR_NUMBER,
6+
IGNORE_AUTHORS,
7+
LABEL_BLOCK,
8+
LABEL_BLOCK_MISSING_LICENSE_AGREEMENT
9+
} = require("./constants")
10+
11+
module.exports = async ({github, context, core}) => {
12+
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
13+
return core.notice("Author in IGNORE_AUTHORS list; skipping...")
14+
}
15+
16+
if (PR_ACTION != "opened") {
17+
return core.notice("Only newly open PRs are labelled to avoid spam; skipping")
18+
}
19+
20+
const RELATED_ACK_SECTION_REGEX = /By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice./;
21+
22+
const isMatch = RELATED_ACK_SECTION_REGEX.exec(PR_BODY);
23+
if (isMatch == null) {
24+
core.info(`No acknowledgement section found, maybe the author didn't use the template but there is one.`)
25+
26+
let msg = "No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template here: https://github.com/awslabs/aws-lambda-powertools-python/blob/develop/.github/PULL_REQUEST_TEMPLATE.md#acknowledgment";
27+
await github.rest.issues.createComment({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
body: msg,
31+
issue_number: PR_NUMBER,
32+
});
33+
34+
return await github.rest.issues.addLabels({
35+
issue_number: PR_NUMBER,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
labels: [LABEL_BLOCK, LABEL_BLOCK_MISSING_LICENSE_AGREEMENT]
39+
})
40+
}
41+
}

.github/workflows/auto_assign.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'Auto Assign'
2+
on:
3+
pull_request:
4+
types: [opened, ready_for_review]
5+
6+
jobs:
7+
add-reviews:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: kentaro-m/auto-assign-action@v1.2.5

.github/workflows/on_opened_pr.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: On new PR
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Record PR details"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
get_pr_details:
11+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
12+
uses: ./.github/workflows/reusable_export_pr_details.yml
13+
with:
14+
record_pr_workflow_id: ${{ github.event.workflow_run.id }}
15+
workflow_origin: ${{ github.event.repository.full_name }}
16+
secrets:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
check_related_issue:
19+
needs: get_pr_details
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: "Ensure related issue is present"
24+
uses: actions/github-script@v6
25+
env:
26+
PR_BODY: ${{ needs.get_pr_details.outputs.prBody }}
27+
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
28+
PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }}
29+
PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }}
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
script: |
33+
const script = require('.github/scripts/label_missing_related_issue.js')
34+
await script({github, context, core})
35+
check_acknowledge_section:
36+
needs: get_pr_details
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v3
40+
- name: "Ensure acknowledgement section is present"
41+
uses: actions/github-script@v6
42+
env:
43+
PR_BODY: ${{ needs.get_pr_details.outputs.prBody }}
44+
PR_NUMBER: ${{ needs.get_pr_details.outputs.prNumber }}
45+
PR_ACTION: ${{ needs.get_pr_details.outputs.prAction }}
46+
PR_AUTHOR: ${{ needs.get_pr_details.outputs.prAuthor }}
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
const script = require('.github/scripts/label_missing_acknowledgement_section.js')
51+
await script({github, context, core})

Unicorn.Contracts/ContractsService.Test/ContractsService.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
1111
<PackageReference Include="Amazon.Lambda.DynamoDBEvents" Version="2.1.1" />
1212
<PackageReference Include="Amazon.Lambda.TestUtilities" Version="2.0.0" />
13-
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.27" />
13+
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.38" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1515
<PackageReference Include="Moq" Version="4.18.4" />
1616
<PackageReference Include="xunit" Version="2.4.2" />

Unicorn.Contracts/ContractsService/ContractsService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.0.1" />
1818
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.0.1" />
1919
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.0.1" />
20-
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.27" />
21-
<PackageReference Include="AWSSDK.EventBridge" Version="3.7.102.3" />
20+
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.38" />
21+
<PackageReference Include="AWSSDK.EventBridge" Version="3.7.102.14" />
2222
<PackageReference Include="AWSXRayRecorder.Handlers.AwsSdk" Version="2.12.0" />
2323
</ItemGroup>
2424
</Project>

Unicorn.Contracts/README.md

Lines changed: 24 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,32 @@
1-
# ContractsService
1+
# Developing Unicorn Contracts
22

3-
This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.
3+
![Contracts Service Architecture](https://static.us-east-1.prod.workshops.aws/public/fd291886-89c4-4336-b21b-5747484b495d/static/images/architecture-contracts.png)
44

5-
- src - Code for the application's Lambda function.
6-
- events - Invocation events that you can use to invoke the function.
7-
- test - Unit tests for the application code.
8-
- template.yaml - A template that defines the application's AWS resources.
5+
## Architecture overview
96

10-
The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the `template.yaml` file in this project. You can update the template to add AWS resources through the same deployment process that updates your application code.
7+
Unicorn Contract manages the contractual relationship between the customers and the Unicorn Properties agency. It's primary function is to allow Unicorn Properties agents to create a new contract for a property listing, and to have the contract approved once it's ready.
118

12-
If you prefer to use an integrated development environment (IDE) to build and test your application, you can use the AWS Toolkit.
13-
The AWS Toolkit is an open source plug-in for popular IDEs that uses the SAM CLI to build and deploy serverless applications on AWS. The AWS Toolkit also adds a simplified step-through debugging experience for Lambda function code. See the following links to get started.
9+
The architecture is fairly straight forward. An API exposes the create contract and update contract methods. This information is recorded in a Amazon DynamoDB table which will contain all latest information about the contract and it's status.
1410

15-
* [CLion](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
16-
* [GoLand](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
17-
* [IntelliJ](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
18-
* [WebStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
19-
* [Rider](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
20-
* [PhpStorm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
21-
* [PyCharm](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
22-
* [RubyMine](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
23-
* [DataGrip](https://docs.aws.amazon.com/toolkit-for-jetbrains/latest/userguide/welcome.html)
24-
* [VS Code](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/welcome.html)
25-
* [Visual Studio](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/welcome.html)
11+
Each time a new contract is created or updated, Unicorn Contracts publishes a `ContractStatusChanged` event to Amazon EventBridge signalling changes to the contract status. These events are consumed by **Unicorn Properties**, so it can track changes to contracts, without needing to take a direct dependency on Unicorn Contracts and it's database.
2612

27-
## Deploy the sample application
13+
Here is an example of an event that is published to EventBridge:
2814

29-
The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.
30-
31-
To use the SAM CLI, you need the following tools.
32-
33-
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
34-
* .NET Core - [Install .NET Core](https://www.microsoft.com/net/download)
35-
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
36-
37-
To build and deploy your application for the first time, run the following in your shell:
38-
39-
```bash
40-
sam build
41-
sam deploy --guided
42-
```
43-
44-
The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:
45-
46-
* **Stack Name**: The name of the stack to deploy to CloudFormation. This should be unique to your account and region, and a good starting point would be something matching your project name.
47-
* **AWS Region**: The AWS region you want to deploy your app to.
48-
* **Confirm changes before deploy**: If set to yes, any change sets will be shown to you before execution for manual review. If set to no, the AWS SAM CLI will automatically deploy application changes.
49-
* **Allow SAM CLI IAM role creation**: Many AWS SAM templates, including this example, create AWS IAM roles required for the AWS Lambda function(s) included to access AWS services. By default, these are scoped down to minimum required permissions. To deploy an AWS CloudFormation stack which creates or modifies IAM roles, the `CAPABILITY_IAM` value for `capabilities` must be provided. If permission isn't provided through this prompt, to deploy this example you must explicitly pass `--capabilities CAPABILITY_IAM` to the `sam deploy` command.
50-
* **Save arguments to samconfig.toml**: If set to yes, your choices will be saved to a configuration file inside the project, so that in the future you can just re-run `sam deploy` without parameters to deploy changes to your application.
51-
52-
You can find your API Gateway Endpoint URL in the output values displayed after deployment.
53-
54-
## Use the SAM CLI to build and test locally
55-
56-
Build your application with the `sam build` command.
57-
58-
```bash
59-
ContractsService$ sam build
60-
```
61-
62-
The SAM CLI installs dependencies defined in `src/HelloWorld.csproj`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
63-
64-
Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the `events` folder in this project.
65-
66-
Run functions locally and invoke them with the `sam local invoke` command.
67-
68-
```bash
69-
ContractsService$ sam local invoke HelloWorldFunction --event events/event.json
70-
```
71-
72-
The SAM CLI can also emulate your application's API. Use the `sam local start-api` to run the API locally on port 3000.
73-
74-
```bash
75-
ContractsService$ sam local start-api
76-
ContractsService$ curl http://localhost:3000/
77-
```
78-
79-
The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The `Events` property on each function's definition includes the route and method for each path.
80-
81-
```yaml
82-
Events:
83-
HelloWorld:
84-
Type: Api
85-
Properties:
86-
Path: /hello
87-
Method: get
88-
```
89-
90-
## Add a resource to your application
91-
The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in [the SAM specification](https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md), you can use standard [AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html) resource types.
92-
93-
## Fetch, tail, and filter Lambda function logs
94-
95-
To simplify troubleshooting, SAM CLI has a command called `sam logs`. `sam logs` lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.
96-
97-
`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
98-
99-
```bash
100-
ContractsService$ sam logs -n HelloWorldFunction --stack-name ContractsService --tail
101-
```
102-
103-
You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).
104-
105-
## Unit tests
106-
107-
Tests are defined in the `test` folder in this project.
108-
109-
```bash
110-
ContractsService$ dotnet test test/HelloWorld.Test
111-
```
112-
113-
## Cleanup
114-
115-
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:
116-
117-
```bash
118-
sam delete --stack-name ContractsService
15+
```json
16+
{
17+
"version": "0",
18+
"account": "123456789012",
19+
"region": "us-east-1",
20+
"detail-type": "ContractStatusChanged",
21+
"source": "unicorn.contracts",
22+
"time": "2022-08-14T22:06:31Z",
23+
"id": "c071bfbf-83c4-49ca-a6ff-3df053957145",
24+
"resources": [],
25+
"detail": {
26+
"contract_updated_on": "10/08/2022 19:56:30",
27+
"ContractId": "617dda8c-e79b-406a-bc5b-3a4712f5e4d7",
28+
"PropertyId": "usa/anytown/main-street/111",
29+
"ContractStatus": "DRAFT"
30+
}
31+
}
11932
```
120-
121-
## Resources
122-
123-
See the [AWS SAM developer guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html) for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
124-
125-
Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/)

Unicorn.Properties/PropertiesService/PropertiesService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.0.1" />
2525
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.0.1" />
2626
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.0.1" />
27-
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.27" />
28-
<PackageReference Include="AWSSDK.StepFunctions" Version="3.7.102.86" />
27+
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.102.38" />
28+
<PackageReference Include="AWSSDK.StepFunctions" Version="3.7.102.97" />
2929
<PackageReference Include="AWSXRayRecorder.Handlers.AwsSdk" Version="2.12.0" />
3030
</ItemGroup>
3131
</Project>

0 commit comments

Comments
 (0)