Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace dynamodb scan with query #31

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
75 changes: 0 additions & 75 deletions .github/workflows/auto-readme.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/auto-release.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Branch
on:
pull_request:
branches:
- main
- release/**
types: [opened, synchronize, reopened]
push:
branches:
- main
- release/v*
paths-ignore:
- '.github/**'
- 'docs/**'
- 'examples/**'
- 'test/**'
- 'README.md'

permissions:
contents: write
actions: write

jobs:
github-action:
uses: cloudposse/.github/.github/workflows/shared-github-action.yml@main
secrets: inherit
16 changes: 9 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Release

on:
release:
types:
- published
types: [published]

permissions:
id-token: write
contents: write
pull-requests: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: cloudposse/github-action-major-release-tagger@v1
github-action:
uses: cloudposse/.github/.github/workflows/shared-release-branches.yml@main
secrets: inherit
9 changes: 6 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185422,7 +185422,8 @@ class DynamoDBMetadataRepo {
return __awaiter(this, void 0, void 0, function* () {
const params = {
TableName: this.tableName,
FilterExpression: "#owner = :owner and #repo = :repo and #commitSHA = :commitSHA and #component = :component and #stack = :stack",
KeyConditionExpression: "#commitSHA= :commitSHA",
FilterExpression: "#owner = :owner and #repo = :repo and #component = :component and #stack = :stack",
ExpressionAttributeNames: {
"#owner": "repoOwner",
"#repo": "repoName",
Expand All @@ -185437,9 +185438,11 @@ class DynamoDBMetadataRepo {
":component": component,
":stack": stack
},
ProjectionExpression: projectionExpression
ProjectionExpression: projectionExpression,
IndexName: "commitSHA-index",
ScanIndexForward: false
};
const command = new lib_dynamodb_1.ScanCommand(params);
const command = new lib_dynamodb_1.QueryCommand(params);
const response = yield this.dynamo.send(command);
if (!response.Items || response.Items.length === 0) {
throw new repository_1.RepositoryErrors.PlanNotFoundError(component, stack, commitSHA);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/modules/terraformPlan/repo/DynamoDbMetadataRepo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
DynamoDBDocumentClient,
ScanCommandInput,
ScanCommand,
QueryCommandInput,
QueryCommand,
PutCommand,
Expand Down Expand Up @@ -30,10 +28,11 @@ export class DynamoDBMetadataRepo implements IMetadataRepository {
stack: string,
commitSHA: string
): Promise<TerraformPlan> {
const params: ScanCommandInput = {
const params: QueryCommandInput = {
TableName: this.tableName,
KeyConditionExpression: "#commitSHA= :commitSHA",
FilterExpression:
"#owner = :owner and #repo = :repo and #commitSHA = :commitSHA and #component = :component and #stack = :stack",
"#owner = :owner and #repo = :repo and #component = :component and #stack = :stack",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing the condition to match the commit SHA? I don't see how this could be correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExpressionAttributeNames: {
"#owner": "repoOwner",
"#repo": "repoName",
Expand All @@ -48,10 +47,12 @@ export class DynamoDBMetadataRepo implements IMetadataRepository {
":component": component,
":stack": stack
},
ProjectionExpression: projectionExpression
ProjectionExpression: projectionExpression,
IndexName: "commitSHA-index",
ScanIndexForward: false
};

const command = new ScanCommand(params);
const command = new QueryCommand(params);
const response = await this.dynamo.send(command);

if (!response.Items || response.Items.length === 0) {
Expand Down
Loading