Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha committed Oct 16, 2024
2 parents 2c73d5b + 117aca4 commit 1e547fa
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 110 deletions.
53 changes: 0 additions & 53 deletions .github/auto-release.yml

This file was deleted.

Binary file added .github/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 70 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@


<!-- markdownlint-disable -->
# github-action-terraform-plan-storage <a href="https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content="><img align="right" src="https://cloudposse.com/logo-300x69.svg" width="150" /></a>
<a href="https://github.com/cloudposse/github-action-terraform-plan-storage/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/github-action-terraform-plan-storage.svg" alt="Latest Release"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/badge.svg" alt="Slack Community"/></a><a href="https://ask.sweetops.com/"><img src="https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg" alt="Discourse Forum"/></a>
<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse/github-action-terraform-plan-storage/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/>
<p align="right">
<a href="https://github.com/cloudposse/github-action-terraform-plan-storage/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/github-action-terraform-plan-storage.svg" alt="Latest Release"/></a><a href="https://slack.cloudposse.com"><img src="https://slack.cloudposse.com/badge.svg" alt="Slack Community"/></a><a href="https://ask.sweetops.com/"><img src="https://img.shields.io/discourse/https/ask.sweetops.com/posts.svg" alt="Discourse Forum"/></a></p>
<!-- markdownlint-restore -->

<!--
Expand All @@ -27,16 +30,16 @@
A GitHub Action to securely store Terraform plan files in a cloud storage (S3 or Azure Blob Storage) with metadata storage in cloud document database (DynamoDB or CosmosDB).


---
> [!NOTE]
> This project is part of Cloud Posse's comprehensive ["SweetOps"](https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=) approach towards DevOps.
> <details><summary><strong>Learn More</strong></summary>
>
> It's 100% Open Source and licensed under the [APACHE2](LICENSE).
> [!TIP]
> #### 👽 Use Atmos with Terraform
> Cloud Posse uses [`atmos`](https://atmos.tools) to easily orchestrate multiple environments using Terraform. <br/>
> Works with [Github Actions](https://atmos.tools/integrations/github-actions/), [Atlantis](https://atmos.tools/integrations/atlantis), or [Spacelift](https://atmos.tools/integrations/spacelift).
>
> </details>
<a href="https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=readme_header_link"><img src="https://cloudposse.com/readme/header/img"/></a>
> <details>
> <summary><strong>Watch demo of using Atmos with Terraform</strong></summary>
> <img src="https://github.com/cloudposse/atmos/blob/master/docs/demo.gif?raw=true"/><br/>
> <i>Example of running <a href="https://atmos.tools"><code>atmos</code></a> to manage infrastructure from our <a href="https://atmos.tools/quick-start/">Quick Start</a> tutorial.</i>
> </detalis>

## Introduction
Expand All @@ -47,9 +50,8 @@ the plan files when a feature branch is opened and applied when merged.



## Usage


## Usage


## AWS (default)
Expand Down Expand Up @@ -128,6 +130,14 @@ Again set the `component`, `stack`, `planPath`, and `action` in the same manner
cosmosEndpoint: "https://my-cosmo-account.documents.azure.com:443/"
```

> [!IMPORTANT]
> In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation
> and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version
> you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic
> approach for updating versions to avoid unexpected changes.






Expand Down Expand Up @@ -180,23 +190,60 @@ For additional context, refer to some of these links.
- [Reference Architectures](https://cloudposse.com/) - Launch effortlessly with our turnkey reference architectures, built either by your team or ours.



> [!TIP]
> #### Use Terraform Reference Architectures for AWS
>
> Use Cloud Posse's ready-to-go [terraform architecture blueprints](https://cloudposse.com/reference-architecture/) for AWS to get up and running quickly.
>
> ✅ We build it together with your team.<br/>
> ✅ Your team owns everything.<br/>
> ✅ 100% Open Source and backed by fanatical support.<br/>
>
> <a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>
> <details><summary>📚 <strong>Learn More</strong></summary>
>
> <br/>
>
> Cloud Posse is the leading [**DevOps Accelerator**](https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support) for funded startups and enterprises.
>
> *Your team can operate like a pro today.*
>
> Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.
> #### Day-0: Your Foundation for Success
> - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code.
> - **Deployment Strategy.** Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases.
> - **Site Reliability Engineering.** Gain total visibility into your applications and services with Datadog, ensuring high availability and performance.
> - **Security Baseline.** Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations.
> - **GitOps.** Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions.
>
> <a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>
>
> #### Day-2: Your Operational Mastery
> - **Training.** Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency.
> - **Support.** Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it.
> - **Troubleshooting.** Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity.
> - **Code Reviews.** Enhance your team’s code quality with our expert feedback, fostering continuous improvement and collaboration.
> - **Bug Fixes.** Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly.
> - **Migration Assistance.** Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value.
> - **Customer Workshops.** Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.
>
> <a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>
> </details>

## ✨ Contributing

This project is under active development, and we encourage contributions from our community.



Many thanks to our outstanding contributors:

<a href="https://github.com/cloudposse/github-action-terraform-plan-storage/graphs/contributors">
<img src="https://contrib.rocks/image?repo=cloudposse/github-action-terraform-plan-storage&max=24" />
</a>

### 🐛 Bug Reports & Feature Requests

Please use the [issue tracker](https://github.com/cloudposse/github-action-terraform-plan-storage/issues) to report any bugs or file feature requests.

### 💻 Developing

If you are interested in being a contributor and want to get involved in developing this project or help out with Cloud Posse's other projects, we would love to hear from you!
Hit us up in [Slack](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=slack), in the `#cloudposse` channel.
For 🐛 bug reports & feature requests, please use the [issue tracker](https://github.com/cloudposse/github-action-terraform-plan-storage/issues).

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
1. Review our [Code of Conduct](https://github.com/cloudposse/github-action-terraform-plan-storage/?tab=coc-ov-file#code-of-conduct) and [Contributor Guidelines](https://github.com/cloudposse/.github/blob/main/CONTRIBUTING.md).
Expand All @@ -221,38 +268,6 @@ Dropped straight into your Inbox every week — and usually a 5-minute read.

[Join us every Wednesday via Zoom](https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=office_hours) for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a _live Q&A_ that you can’t find anywhere else.
It's **FREE** for everyone!

## About

This project is maintained by <a href="https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=">Cloud Posse, LLC</a>.
<a href="https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content="><img src="https://cloudposse.com/logo-300x69.svg" align="right" /></a>

We are a [**DevOps Accelerator**](https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support) for funded startups and enterprises.
Use our ready-to-go terraform architecture blueprints for AWS to get up and running quickly.
We build it with you. You own everything. Your team wins. Plus, we stick around until you succeed.

<a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=commercial_support"><img alt="Learn More" src="https://img.shields.io/badge/learn%20more-success.svg?style=for-the-badge"/></a>

*Your team can operate like a pro today.*

Ensure that your team succeeds by using our proven process and turnkey blueprints. Plus, we stick around until you succeed.

<details>
<summary>📚 <strong>See What's Included</strong></summary>

- **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code.
- **Deployment Strategy.** You'll have a battle-tested deployment strategy using GitHub Actions that's automated and repeatable.
- **Site Reliability Engineering.** You'll have total visibility into your apps and microservices.
- **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes.
- **GitOps.** You'll be able to operate your infrastructure via Pull Requests.
- **Training.** You'll receive hands-on training so your team can operate what we build.
- **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel.
- **Troubleshooting.** You'll get help to triage when things aren't working.
- **Code Reviews.** You'll receive constructive feedback on Pull Requests.
- **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects.
</details>

<a href="https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/github-action-terraform-plan-storage&utm_content=readme_commercial_support_link"><img src="https://cloudposse.com/readme/commercial-support/img"/></a>
## License

<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge" alt="License"></a>
Expand Down Expand Up @@ -287,6 +302,8 @@ under the License.
## Trademarks

All other trademarks referenced herein are the property of their respective owners.


## Copyrights

Copyright © 2023-2024 [Cloud Posse, LLC](https://cloudposse.com)
Expand Down
23 changes: 22 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185422,8 +185422,13 @@ class DynamoDBMetadataRepo {
return __awaiter(this, void 0, void 0, function* () {
const params = {
TableName: this.tableName,
<<<<<<< HEAD
KeyConditionExpression: "#commitSHA= :commitSHA",
FilterExpression: "#owner = :owner and #repo = :repo and #component = :component and #stack = :stack",
=======
ExclusiveStartKey: undefined,
FilterExpression: "#owner = :owner and #repo = :repo and #commitSHA = :commitSHA and #component = :component and #stack = :stack",
>>>>>>> main
ExpressionAttributeNames: {
"#owner": "repoOwner",
"#repo": "repoName",
Expand All @@ -185442,13 +185447,29 @@ class DynamoDBMetadataRepo {
IndexName: "commitSHA-index",
ScanIndexForward: false
};
<<<<<<< HEAD
const command = new lib_dynamodb_1.QueryCommand(params);
const response = yield this.dynamo.send(command);
if (!response.Items || response.Items.length === 0) {
=======
let results = [];
let response;
do {
const command = new lib_dynamodb_1.ScanCommand(params);
response = yield this.dynamo.send(command);
if (response.Items && response.Items.length >= 0) {
results = results.concat(response.Items);
}
if (response.LastEvaluatedKey) {
params.ExclusiveStartKey = response.LastEvaluatedKey;
}
} while (response.LastEvaluatedKey);
if (results.length === 0) {
>>>>>>> main
throw new repository_1.RepositoryErrors.PlanNotFoundError(component, stack, commitSHA);
}
const items = [];
response.Items.forEach((item) => {
results.forEach((item) => {
items.push(this.mapper.toDomain(item));
});
const sortedItems = items.sort((a, b) => {
Expand Down
6 changes: 5 additions & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions src/modules/terraformPlan/repo/DynamoDbMetadataRepo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import {
DynamoDBDocumentClient,
<<<<<<< HEAD
=======
ScanCommandInput,
ScanCommandOutput,
ScanCommand,
>>>>>>> main
QueryCommandInput,
QueryCommand,
PutCommand,
Expand All @@ -10,6 +16,7 @@ import {
TerraformPlan,
TerraformPlanDynamoDBMapper
} from "@modules/terraformPlan";
import {NativeAttributeValue} from "@aws-sdk/util-dynamodb";

const projectionExpression =
"id, branch, commitSHA, component, contentsHash, repoOwner, pr, repoName, stack, tainted, createdAt";
Expand Down Expand Up @@ -55,12 +62,25 @@ export class DynamoDBMetadataRepo implements IMetadataRepository {
const command = new QueryCommand(params);
const response = await this.dynamo.send(command);

if (!response.Items || response.Items.length === 0) {
do {
const command = new ScanCommand(params);
response = await this.dynamo.send(command);

if (response.Items && response.Items.length >= 0) {
results = results.concat(response.Items)
}

if (response.LastEvaluatedKey) {
params.ExclusiveStartKey = response.LastEvaluatedKey
}
} while (response.LastEvaluatedKey)

if (results.length === 0) {
throw new RepositoryErrors.PlanNotFoundError(component, stack, commitSHA);
}

const items: TerraformPlan[] = [];
response.Items.forEach((item) => {
results.forEach((item) => {
items.push(this.mapper.toDomain(item));
});

Expand Down

0 comments on commit 1e547fa

Please sign in to comment.