-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from boyney123/feat-adding-dynamodb
Adding DynamoDB
- Loading branch information
Showing
30 changed files
with
1,004 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@cloudcatalog/cli": patch | ||
"@cloudcatalog/core": patch | ||
"@cloudcatalog/create-catalog": patch | ||
--- | ||
|
||
feat- Adding DynamoDB resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
name: user-payments | ||
description: Table storing user payments information | ||
service: payment-service | ||
owners: | ||
- dboyne | ||
- payment-team | ||
AWS: | ||
Arn: arn:aws:dynamodb:us-west-2:123456789123:table/user-payments | ||
TableName: user-payments | ||
CreationDateTime: '2022-09-15T09:56:47.097Z' | ||
DeletionProtectionEnabled: false | ||
TableStatus: ACTIVE | ||
TableSizeBytes: 76 | ||
StreamSpecification: | ||
StreamEnabled: true | ||
StreamViewType: NEW_AND_OLD_IMAGES | ||
ProvisionedThroughput: | ||
ReadCapacityUnits: 1 | ||
WriteCapacityUnits: 1 | ||
AttributeDefinitions: | ||
- AttributeName: id | ||
AttributeType: S | ||
Service: dynamodb | ||
AccountId: 123456789123 | ||
catalog: | ||
updatedAt: '2024-01-10T07:48:19.106Z' | ||
parent: dynamodb | ||
path: user-payments | ||
--- | ||
|
||
## About this table | ||
|
||
The user-payments table is an integral component of our payment service, designed to efficiently manage and store transactional data related to user payments. This table serves as a central repository for payment records, ensuring secure and rapid access to transaction details. | ||
|
||
## Access patterns | ||
|
||
### Retrieve User Transaction History | ||
- **Use Case**: Fetch all transactions made by a specific user. | ||
- **Query Pattern**: Query the table using the userId as the partition key. This returns all items with the matching userId, sorted by transactionId. | ||
- **Example Query**: `SELECT * FROM user-payments WHERE userId = :userId` | ||
|
||
### Lookup Specific Transaction | ||
|
||
- **Use Case**: Retrieve details of a specific transaction for a user. | ||
- **Query Pattern**: Use both userId (partition key) and transactionId (sort key) to get the specific transaction record. | ||
- **Example Query**: `SELECT * FROM user-payments WHERE userId = :userId AND transactionId = :transactionId` | ||
|
||
### Query Transactions Based on Status | ||
|
||
- **Use Case**: Identify transactions that are pending, successful, or failed. | ||
- **Implementation**: This may require the use of a Global Secondary Index (GSI) with status as the key if frequent queries are made based on the transaction status. | ||
- **Example Query**: `SELECT * FROM user-payments-index-status WHERE status = :status` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
name: users | ||
description: Table for storing user information | ||
service: user-service | ||
owners: | ||
- dboyne | ||
- user-team | ||
AWS: | ||
Arn: arn:aws:dynamodb:us-west-2:123456789123:table/user-payments | ||
TableName: user-payments | ||
CreationDateTime: '2022-09-15T09:56:47.097Z' | ||
DeletionProtectionEnabled: false | ||
TableStatus: ACTIVE | ||
TableSizeBytes: 762 | ||
StreamSpecification: | ||
StreamEnabled: true | ||
StreamViewType: NEW_AND_OLD_IMAGES | ||
ProvisionedThroughput: | ||
ReadCapacityUnits: 1 | ||
WriteCapacityUnits: 1 | ||
AttributeDefinitions: | ||
- AttributeName: id | ||
AttributeType: S | ||
Service: dynamodb | ||
AccountId: 123456789123 | ||
catalog: | ||
updatedAt: '2024-01-10T07:48:19.106Z' | ||
parent: dynamodb | ||
path: users | ||
--- | ||
|
||
## About this table | ||
|
||
The users table is an integral part of our infrastructure, serving as the backbone for managing user data. This table is tailored to support various user-related functionalities across our applications, including authentication, profile management, and user activity tracking. It is optimized for high performance and scalability to handle our growing user base. | ||
|
||
## Access patterns | ||
|
||
### User Authentication: | ||
- Primary access pattern involves querying by `userID` or `email` to retrieve credentials and perform authentication checks. | ||
- Example Query: Retrieve user details by `email` for login purposes. | ||
|
||
### Profile Information Retrieval: | ||
|
||
- Frequently accessed for displaying user profile information. | ||
- Example Query: Fetch complete user details by `userID` for profile viewing or editing. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { | ||
DynamoDBClient, | ||
DescribeTableCommand, | ||
TableStatus, | ||
StreamSpecification, | ||
ProvisionedThroughput, | ||
ProvisionedThroughputDescription, | ||
AttributeDefinition, | ||
} from "@aws-sdk/client-dynamodb"; | ||
import { parse } from "@aws-sdk/util-arn-parser"; | ||
// import chalk from "chalk"; | ||
const client = new DynamoDBClient({}); | ||
|
||
export interface Data { | ||
name?: string; | ||
description?: string; | ||
AWS: { | ||
Arn: string; | ||
TableName?: string; | ||
CreationDateTime: string | undefined; | ||
TableStatus: string | undefined; | ||
DeletionProtectionEnabled?: boolean; | ||
TableSizeBytes?: number | undefined; | ||
StreamSpecification?: StreamSpecification; | ||
ProvisionedThroughput?: ProvisionedThroughputDescription; | ||
AttributeDefinitions?: AttributeDefinition[]; | ||
Account: string; | ||
Service: string; | ||
}; | ||
} | ||
|
||
// arn:aws:dynamodb:us-west-2:123456789123:table/boynestore-users | ||
|
||
// Code that runs to get information about the resource. | ||
export const getData = async (arn: string): Promise<Data> => { | ||
const { resource, accountId } = parse(arn); | ||
const tableName = resource.split("table/")[1]; | ||
|
||
const response = await client.send( | ||
new DescribeTableCommand({ | ||
TableName: tableName, | ||
}), | ||
); | ||
|
||
const creationDate = response.Table?.CreationDateTime; | ||
|
||
console.log("response", JSON.stringify(response, null, 4)); | ||
|
||
return { | ||
name: response.Table?.TableName, | ||
description: "DynamoDB Table", | ||
AWS: { | ||
Arn: arn, | ||
TableName: response.Table?.TableName, | ||
CreationDateTime: creationDate | ||
? response.Table?.CreationDateTime?.toISOString() | ||
: undefined, | ||
DeletionProtectionEnabled: response.Table?.DeletionProtectionEnabled, | ||
TableStatus: response.Table?.TableStatus, | ||
TableSizeBytes: response.Table?.TableSizeBytes, | ||
StreamSpecification: response.Table?.StreamSpecification, | ||
ProvisionedThroughput: { | ||
ReadCapacityUnits: | ||
response?.Table?.ProvisionedThroughput?.ReadCapacityUnits, | ||
WriteCapacityUnits: | ||
response?.Table?.ProvisionedThroughput?.WriteCapacityUnits, | ||
}, | ||
AttributeDefinitions: response.Table?.AttributeDefinitions, | ||
Account: accountId, | ||
Service: "dynamodb", | ||
}, | ||
}; | ||
}; | ||
|
||
// Return the default markdown for new resources | ||
export const getMarkdown = (data: Data): Promise<string> => { | ||
return Promise.resolve(` | ||
## About this table | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum in ligula et orci pellentesque volutpat. In imperdiet augue sit amet imperdiet ultricies. Etiam eget dui elementum, tempor ligula quis, consectetur eros. Suspendisse sodales mattis ex, nec tempor lorem. Maecenas eget risus suscipit, gravida lectus eu, dictum sapien. Nunc efficitur sem eget dui tempus aliquam. | ||
`); | ||
}; | ||
export const getFileName = (data: Data): Promise<string> => { | ||
const name = data.AWS.TableName || `new-${data.AWS.TableName}-file`; | ||
return Promise.resolve(name); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4467823
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cloudcatalog-demo – ./packages/cloudcatalog
app.cloudcatalog.dev
cloudcatalog-demo-davidboyne123.vercel.app
cloudcatalog-demo-git-main-davidboyne123.vercel.app
cloudcatalog-demo.vercel.app