Skip to content

Commit

Permalink
Merge branch 'main' into updateDatadogDefaultFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-mckay authored Nov 27, 2024
2 parents 89a75ee + a4ff422 commit 4af3605
Show file tree
Hide file tree
Showing 42 changed files with 2,244 additions and 1,089 deletions.
5 changes: 0 additions & 5 deletions .changeset/neat-adults-march.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/short-poems-sleep.md

This file was deleted.

21 changes: 21 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# backend

## 2.2.0

### Minor Changes

- ac7b6e7: Implement AWS SNS Topic provider

### Patch Changes

- Updated dependencies [ac7b6e7]
- @roadiehq/catalog-backend-module-aws@5.2.0
- @roadiehq/backstage-plugin-aws-backend@1.2.0

## 2.1.26

### Patch Changes

- Updated dependencies [904ba81]
- Updated dependencies [9fb8723]
- @roadiehq/scaffolder-backend-module-utils@3.0.0
- @roadiehq/scaffolder-backend-module-http-request@5.0.0

## 2.1.25

### Patch Changes
Expand Down
14 changes: 8 additions & 6 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "backend",
"version": "2.1.25",
"version": "2.2.0",
"main": "dist/index.cjs.js",
"types": "src/index.ts",
"private": true,
"backstage": {
"role": "backend"
},
"engines": {
"node": "14 || 16 || 18"
"node": "14 || 16 || 18 || 20"
},
"scripts": {
"build": "backstage-cli package build",
Expand Down Expand Up @@ -36,7 +36,9 @@
"@backstage/plugin-permission-node": "^0.8.4",
"@backstage/plugin-proxy-backend": "^0.5.7",
"@backstage/plugin-scaffolder-backend": "^1.26.1",
"@backstage/plugin-scaffolder-node": "^0.5.0",
"@backstage/plugin-techdocs-backend": "^1.11.0",
"@backstage/plugin-catalog-backend-module-scaffolder-entity-model": "^0.2.2",
"@gitbeaker/node": "^35.1.0",
"@langchain/community": "^0.2.28",
"@langchain/core": "^0.2.27",
Expand All @@ -45,8 +47,8 @@
"@roadiehq/backstage-plugin-argo-cd-backend": "3.2.3",
"@roadiehq/plugin-wiz-backend": "^1.0.0",
"@roadiehq/backstage-plugin-aws-auth": "^0.4.26",
"@roadiehq/backstage-plugin-aws-backend": "^1.1.26",
"@roadiehq/catalog-backend-module-aws": "^5.0.4",
"@roadiehq/backstage-plugin-aws-backend": "^1.2.0",
"@roadiehq/catalog-backend-module-aws": "^5.2.0",
"@roadiehq/catalog-backend-module-okta": "^1.0.3",
"@roadiehq/rag-ai-backend": "^1.2.0",
"@roadiehq/rag-ai-backend-embeddings-aws": "^1.0.0",
Expand All @@ -55,8 +57,8 @@
"@roadiehq/rag-ai-storage-pgvector": "^1.0.2",
"@roadiehq/catalog-backend-module-gravatar": "^1.0.5",
"@roadiehq/scaffolder-backend-module-aws": "^2.4.26",
"@roadiehq/scaffolder-backend-module-http-request": "^4.3.5",
"@roadiehq/scaffolder-backend-module-utils": "^2.0.2",
"@roadiehq/scaffolder-backend-module-http-request": "^5.0.0",
"@roadiehq/scaffolder-backend-module-utils": "^3.0.0",
"app": "^1.1.8",
"better-sqlite3": "^9.0.0",
"dockerode": "^3.3.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/plugins/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
CatalogBuilder,
EntityProvider,
} from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
import {
Expand All @@ -32,6 +32,7 @@ import {
AWSEC2Provider,
AWSRDSProvider,
AWSOrganizationAccountsProvider,
AWSSNSTopicProvider,
} from '@roadiehq/catalog-backend-module-aws';
import { OktaOrgEntityProvider } from '@roadiehq/catalog-backend-module-okta';
import { Duration } from 'luxon';
Expand Down Expand Up @@ -65,6 +66,7 @@ export default async function createPlugin(
const s3Provider = AWSS3BucketProvider.fromConfig(config, env);
const lambdaProvider = AWSLambdaFunctionProvider.fromConfig(config, env);
const iamUserProvider = AWSIAMUserProvider.fromConfig(config, env);
const snsTopicProvider = AWSSNSTopicProvider.fromConfig(config, env);
const iamRoleProvider = AWSIAMRoleProvider.fromConfig(config, env);
const ddbTableProvider = AWSDynamoDbTableProvider.fromConfig(config, env);
const eksClusterProvider = AWSEKSClusterProvider.fromConfig(config, env);
Expand All @@ -78,6 +80,7 @@ export default async function createPlugin(
builder.addEntityProvider(s3Provider);
builder.addEntityProvider(lambdaProvider);
builder.addEntityProvider(iamUserProvider);
builder.addEntityProvider(snsTopicProvider);
builder.addEntityProvider(iamRoleProvider);
builder.addEntityProvider(ddbTableProvider);
builder.addEntityProvider(eksClusterProvider);
Expand All @@ -88,6 +91,7 @@ export default async function createPlugin(
providers.push(lambdaProvider);
providers.push(iamUserProvider);
providers.push(iamRoleProvider);
providers.push(snsTopicProvider);
providers.push(ddbTableProvider);
providers.push(eksClusterProvider);
providers.push(ec2Provider);
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/plugins/scaffolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {
DockerContainerRunner,
} from '@backstage/backend-common';
import { CatalogClient } from '@backstage/catalog-client';
import { TemplateAction } from '@backstage/plugin-scaffolder-node';
import {
createBuiltinActions,
createRouter,
TemplateAction,
} from '@backstage/plugin-scaffolder-backend';
import { createHttpBackstageAction } from '@roadiehq/scaffolder-backend-module-http-request';
import {
Expand Down
6 changes: 6 additions & 0 deletions plugins/backend/backstage-aws-backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @roadiehq/backstage-plugin-aws-backend

## 1.2.0

### Minor Changes

- ac7b6e7: Implement AWS SNS Topic provider

## 1.1.26

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions plugins/backend/backstage-aws-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@roadiehq/backstage-plugin-aws-backend",
"version": "1.1.26",
"version": "1.2.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down Expand Up @@ -41,7 +41,7 @@
"@backstage/catalog-client": "^1.7.1",
"@backstage/config": "^1.2.0",
"@types/express": "^4.17.6",
"@aws-sdk/client-cloudcontrol": "^3.76.0",
"@aws-sdk/client-cloudcontrol": "^3.696.0",
"@aws-sdk/credential-providers": "^3.76.0",
"express": "^4.17.1",
"express-promise-router": "^4.1.0",
Expand Down
6 changes: 6 additions & 0 deletions plugins/backend/catalog-backend-module-aws/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @backstage/plugin-catalog-backend-module-aws

## 5.2.0

### Minor Changes

- ac7b6e7: Implement AWS SNS Topic provider

## 5.1.0

### Minor Changes
Expand Down
30 changes: 16 additions & 14 deletions plugins/backend/catalog-backend-module-aws/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@roadiehq/catalog-backend-module-aws",
"description": "A set of Backstage catalog providers for AWS",
"version": "5.1.0",
"version": "5.2.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down Expand Up @@ -39,18 +39,19 @@
"start": "backstage-cli package start"
},
"dependencies": {
"@aws-sdk/client-cloudcontrol": "^3.76.0",
"@aws-sdk/client-dynamodb": "^3.76.0",
"@aws-sdk/client-ec2": "^3.76.0",
"@aws-sdk/client-eks": "^3.76.0",
"@aws-sdk/client-iam": "^3.76.0",
"@aws-sdk/client-lambda": "^3.76.0",
"@aws-sdk/client-organizations": "^3.76.0",
"@aws-sdk/client-rds": "^3.76.0",
"@aws-sdk/client-s3": "^3.76.0",
"@aws-sdk/client-sts": "^3.76.0",
"@aws-sdk/credential-providers": "^3.76.0",
"@aws-sdk/lib-dynamodb": "^3.76.0",
"@aws-sdk/client-cloudcontrol": "^3.696.0",
"@aws-sdk/client-dynamodb": "^3.696.0",
"@aws-sdk/client-ec2": "^3.696.0",
"@aws-sdk/client-eks": "^3.696.0",
"@aws-sdk/client-iam": "^3.696.0",
"@aws-sdk/client-lambda": "^3.696.0",
"@aws-sdk/client-organizations": "^3.696.0",
"@aws-sdk/client-rds": "^3.696.0",
"@aws-sdk/client-s3": "^3.696.0",
"@aws-sdk/client-sts": "^3.696.0",
"@aws-sdk/client-sns": "^3.696.0",
"@aws-sdk/credential-providers": "^3.696.0",
"@aws-sdk/lib-dynamodb": "^3.696.0",
"@backstage/integration-aws-node": "^0.1.12",
"@backstage/backend-common": "^0.25.0",
"@backstage/catalog-client": "^1.7.1",
Expand All @@ -72,7 +73,8 @@
"@testing-library/jest-dom": "^6.4.2",
"@types/link2aws": "^1.0.0",
"@types/lodash": "^4.14.151",
"aws-sdk-client-mock": "^0.6.2",
"@aws-sdk/types": "^3.696.0",
"aws-sdk-client-mock": "^4.1.0",
"yaml": "^2.2.2"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

export const ANNOTATION_AWS_IAM_ROLE_ARN = 'amazon.com/iam-role-arn';
export const ANNOTATION_AWS_IAM_USER_ARN = 'amazon.com/iam-user-arn';
export const ANNOTATION_AWS_SNS_TOPIC_ARN = 'amazon.com/sns-topic-arn';
export const ANNOTATION_AWS_LAMBDA_FUNCTION_ARN =
'amazon.com/lambda-function-arn';
export const ANNOTATION_AWS_S3_BUCKET_ARN = 'amazon.com/s3-bucket-arn';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright 2021 Larder Software Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { SNS, ListTopicsCommand, Topic } from '@aws-sdk/client-sns';
import { STS, GetCallerIdentityCommand } from '@aws-sdk/client-sts';

import { mockClient } from 'aws-sdk-client-mock';
import { createLogger, transports } from 'winston';
import { AWSSNSTopicProvider } from './AWSSNSTopicProvider';
import { ConfigReader } from '@backstage/config';
import { EntityProviderConnection } from '@backstage/plugin-catalog-backend';

const sns = mockClient(SNS);
const sts = mockClient(STS);

const logger = createLogger({
transports: [new transports.Console({ silent: true })],
});

describe('AWSSNSTopicProvider', () => {
const config = new ConfigReader({
accountId: '123456789012',
roleName: 'arn:aws:iam::123456789012:role/role1',
region: 'eu-west-1',
});

beforeEach(() => {
sts.on(GetCallerIdentityCommand).resolves({});
sns.reset(); // Ensure the mock client is reset before each test
});

describe('when there are no SNS topics', () => {
beforeEach(() => {
sns.on(ListTopicsCommand).resolves({
Topics: [],
});
});

it('creates no SNS topics', async () => {
const entityProviderConnection: EntityProviderConnection = {
applyMutation: jest.fn(),
refresh: jest.fn(),
};
const provider = AWSSNSTopicProvider.fromConfig(config, { logger });
provider.connect(entityProviderConnection);
await provider.run();
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
type: 'full',
entities: [],
});
});
});

describe('when there are SNS topics', () => {
beforeEach(() => {
sns.on(ListTopicsCommand).resolves({
Topics: [
{
TopicArn: 'arn:aws:sns:eu-west-1:123456789012:example-topic',
} as Partial<Topic> as any,
],
});
});

it('creates SNS topic entities', async () => {
const entityProviderConnection: EntityProviderConnection = {
applyMutation: jest.fn(),
refresh: jest.fn(),
};
const provider = AWSSNSTopicProvider.fromConfig(config, { logger });
provider.connect(entityProviderConnection);
await provider.run();
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
type: 'full',
entities: [
expect.objectContaining({
entity: expect.objectContaining({
kind: 'Resource',
metadata: expect.objectContaining({
name: 'example-topic',
title: 'example-topic',
annotations: expect.objectContaining({
'backstage.io/view-url':
'https://console.aws.amazon.com/sns/v3/home?region=eu-west-1#/topic/arn:aws:sns:eu-west-1:123456789012:example-topic',
}),
}),
}),
}),
],
});
});
});
});
Loading

0 comments on commit 4af3605

Please sign in to comment.