Skip to content

Commit

Permalink
feat: move to NordicSemiconductor organization
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this renames the package

See bifravst/bifravst#56
  • Loading branch information
coderbyheart committed Feb 2, 2021
1 parent c6e4788 commit 3a040f8
Show file tree
Hide file tree
Showing 57 changed files with 4,907 additions and 5,145 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@bifravst/eslint-config-typescript"
"extends": "@nordicsemiconductor/eslint-config-asset-tracker-cloud-typescript"
}
2 changes: 1 addition & 1 deletion .github/workflows/npm-prerelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

jobs:
main:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on: push

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_SECRET_ACCESS_KEY }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1
AWS_DEFAULT_REGION: eu-west-1
CI: 1
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Generate Stack ID
run: |
RANDOM_STRING=`node -e "const crypto = require('crypto'); process.stdout.write(crypto.randomBytes(Math.ceil(8 * 0.5)).toString('hex').slice(0, 8));"`
echo "STACK_NAME=bifravst-${{ runner.OS }}-${RANDOM_STRING}" >> $GITHUB_ENV
echo "STACK_NAME=asset-tracker-${{ runner.OS }}-${RANDOM_STRING}" >> $GITHUB_ENV
- run: aws sts get-caller-identity
- run: echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV
- name: Set up stack for End-to-End tests
Expand Down
8 changes: 4 additions & 4 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ pull_request_rules:
- name: Automatic merge security PRs when all status checks pass
conditions:
- author~=^(snyk-bot|dependabot\[bot\])$
- status-success=security/snyk (Bifravst)
- status-success=security/snyk (Asset Tracker Cloud)
- status-success=tests (ubuntu-latest)
- status-success=tests (macos-latest)
actions:
merge:
method: rebase
rebase_fallback: squash
bot_account: bifravst-ci
bot_account: asset-tracker-cloud-ci
label:
add:
- mergify
- mergify
rebase:
bot_account: bifravst-ci
bot_account: asset-tracker-cloud-ci
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require('@bifravst/code-style/.prettierrc'),
...require('@nordicsemiconductor/asset-tracker-cloud-code-style/.prettierrc'),
}
3 changes: 2 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
See https://github.com/bifravst/bifravst/blob/saga/CODE_OF_CONDUCT.md
See
https://github.com/NordicSemiconductor/asset-tracker-cloud-docs/blob/saga/CODE_OF_CONDUCT.md
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# AWS-based implementation of _Bifravst :smirk_cat::rainbow:_ [![npm version](https://img.shields.io/npm/v/@bifravst/aws.svg)](https://www.npmjs.com/package/@bifravst/aws)
# Asset Tracker Example for AWS [![npm version](https://img.shields.io/npm/v/@nordicsemiconductor/asset-tracker-cloud-aws.svg)](https://www.npmjs.com/package/@nordicsemiconductor/asset-tracker-cloud-aws)

[![GitHub Actions](https://github.com/bifravst/aws/workflows/Test%20and%20Release/badge.svg)](https://github.com/bifravst/aws/actions)
[![Known Vulnerabilities](https://snyk.io/test/github/bifravst/aws/badge.svg)](https://snyk.io/test/github/bifravst/aws)
[![GitHub Actions](https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js/workflows/Test%20and%20Release/badge.svg)](https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js/actions)
[![Known Vulnerabilities](https://snyk.io/test/github/NordicSemiconductor/asset-tracker-cloud-aws-js/badge.svg?targetFile=package.json)](https://snyk.io/test/github/NordicSemiconductor/asset-tracker-cloud-aws-js?targetFile=package.json)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
[![Mergify Status](https://img.shields.io/endpoint.svg?url=https://dashboard.mergify.io/badges/bifravst/aws&style=flat)](https://mergify.io)
[![Mergify Status](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/NordicSemiconductor/asset-tracker-cloud-aws-js)](https://mergify.io)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier/)
[![ESLint: TypeScript](https://img.shields.io/badge/ESLint-TypeScript-blue.svg)](https://github.com/typescript-eslint/typescript-eslint)

Read the documentation at https://bifravst.github.io/.
A reference implementation of a serverless backend for an IoT product developed
using [AWS CDK](https://aws.amazon.com/cdk) in
[TypeScript](https://www.typescriptlang.org/).

> :information_source:
> [Read the complete Asset Tracker Cloud Example documentation](https://nordicsemiconductor.github.io/asset-tracker-cloud-docs/).
12 changes: 6 additions & 6 deletions cdk/apps/Bifravst.ts → cdk/apps/AssetTracker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { App } from '@aws-cdk/core'
import { BifravstStack } from '../stacks/Bifravst'
import { AssetTrackerStack } from '../stacks/AssetTracker'
import { WebAppStack } from '../stacks/WebApp'
import {
BifravstLambdas,
AssetTrackerLambdas,
CDKLambdas,
PackedLambdas,
} from '../prepare-resources'
Expand All @@ -14,18 +14,18 @@ import { ContinuousDeploymentStack } from '../stacks/ContinuousDeployment'
import { extractRepoAndOwner } from '../helper/extract-repo-and-owner'
import { enabledInContext } from '../helper/enabledInContext'

export class BifravstApp extends App {
export class AssetTrackerApp extends App {
public constructor(args: {
mqttEndpoint: string
sourceCodeBucketName: string
packedLambdas: PackedLambdas<BifravstLambdas>
packedLambdas: PackedLambdas<AssetTrackerLambdas>
packedCDKLambdas: PackedLambdas<CDKLambdas>
enableUnwiredApi: boolean
context?: Record<string, any>
}) {
super({ context: args.context })
// Core
new BifravstStack(this, {
new AssetTrackerStack(this, {
...args,
})
const checkFlag = enabledInContext(this.node)
Expand Down Expand Up @@ -60,7 +60,7 @@ export class BifravstApp extends App {
readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'),
)
new ContinuousDeploymentStack(this, {
bifravstAWS: {
core: {
...extractRepoAndOwner(pjson.repository.url),
branch: pjson.deploy.branch ?? 'saga',
},
Expand Down
8 changes: 4 additions & 4 deletions cdk/apps/Test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { App } from '@aws-cdk/core'
import { BifravstStack } from '../stacks/Bifravst'
import { AssetTrackerStack } from '../stacks/AssetTracker'
import {
BifravstLambdas,
AssetTrackerLambdas,
CDKLambdas,
PackedLambdas,
} from '../prepare-resources'
Expand All @@ -14,12 +14,12 @@ export class TestApp extends App {
public constructor(args: {
mqttEndpoint: string
sourceCodeBucketName: string
packedLambdas: PackedLambdas<BifravstLambdas>
packedLambdas: PackedLambdas<AssetTrackerLambdas>
packedCDKLambdas: PackedLambdas<CDKLambdas>
context?: Record<string, any>
}) {
super({ context: args.context })
new BifravstStack(this, {
new AssetTrackerStack(this, {
...args,
enableUnwiredApi: false, // FIXME: implement e2e test
})
Expand Down
4 changes: 2 additions & 2 deletions cdk/cloudformation-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestApp } from './apps/Test'
import {
prepareBifravstLambdas,
prepareAssetTrackerLambdas,
prepareCDKLambdas,
prepareResources,
} from './prepare-resources'
Expand All @@ -12,7 +12,7 @@ prepareResources({
})
.then(async (res) => ({
...res,
packedLambdas: await prepareBifravstLambdas({
packedLambdas: await prepareAssetTrackerLambdas({
...res,
rootDir,
}),
Expand Down
8 changes: 4 additions & 4 deletions cdk/cloudformation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BifravstApp } from './apps/Bifravst'
import { AssetTrackerApp } from './apps/AssetTracker'
import {
prepareResources,
prepareBifravstLambdas,
prepareAssetTrackerLambdas,
prepareCDKLambdas,
} from './prepare-resources'
import { SSMClient } from '@aws-sdk/client-ssm'
Expand All @@ -21,7 +21,7 @@ Promise.all([
rootDir,
}).then(async (res) => ({
...res,
packedLambdas: await prepareBifravstLambdas({
packedLambdas: await prepareAssetTrackerLambdas({
...res,
rootDir,
}),
Expand All @@ -40,7 +40,7 @@ Promise.all([
loadContext({ sts: new STSClient({}) }),
])
.then(([args, ulApiSettings, context]) =>
new BifravstApp({
new AssetTrackerApp({
...args,
enableUnwiredApi: 'apiKey' in ulApiSettings,
context: {
Expand Down
5 changes: 4 additions & 1 deletion cdk/createThingGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
} from '@aws-sdk/client-iot'
import { CloudFormationCustomResourceEvent } from 'aws-lambda'
import { paginate } from '../util/paginate'
import { cfnResponse, ResponseStatus } from '@bifravst/cloudformation-helpers'
import {
cfnResponse,
ResponseStatus,
} from '@nordicsemiconductor/cloudformation-helpers'

const iot = new IoTClient({})

Expand Down
6 changes: 3 additions & 3 deletions cdk/helper/addFakeRoute.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { stackOutput } from '@bifravst/cloudformation-helpers'
import { stackOutput } from '@nordicsemiconductor/cloudformation-helpers'
import {
ApiGatewayV2Client,
CreateRouteCommand,
} from '@aws-sdk/client-apigatewayv2'
import { CloudFormationClient } from '@aws-sdk/client-cloudformation'
import { StackOutputs } from '../stacks/Bifravst'
import { StackOutputs } from '../stacks/AssetTracker'
import { CORE_STACK_NAME } from '../stacks/stackName'
import { v4 } from 'uuid'

/**
* This creates a fake route after CloudFormation has finished deploying the
* HTTP API in order to address it's flaky behaviour.
*
* @see https://github.com/bifravst/aws/issues/455
* @see https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js/issues/455
*/
const main = async () => {
const { geolocationApiId } = await stackOutput(
Expand Down
8 changes: 5 additions & 3 deletions cdk/helper/extract-repo-and-owner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { extractRepoAndOwner } from './extract-repo-and-owner'
describe('extractRepoAndOwner()', () => {
it('should parse a git repo', () => {
expect(
extractRepoAndOwner('git+https://github.com/bifravst/aws.git'),
extractRepoAndOwner(
'git+https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js.git',
),
).toEqual({
owner: 'bifravst',
repo: 'aws',
owner: 'NordicSemiconductor',
repo: 'asset-tracker-cloud-aws-js',
})
})
})
20 changes: 10 additions & 10 deletions cdk/prepare-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
packBaseLayer,
packLayeredLambdas,
WebpackMode,
} from '@bifravst/package-layered-lambdas'
} from '@nordicsemiconductor/package-layered-lambdas'
import { supportedRegions } from './regions'
import * as chalk from 'chalk'
import { getIotEndpoint } from './helper/getIotEndpoint'
import { spawn } from 'child_process'
import { ConsoleProgressReporter } from '@bifravst/package-layered-lambdas/dist/src/reporter'
import { ConsoleProgressReporter } from '@nordicsemiconductor/package-layered-lambdas/dist/src/reporter'

export type CDKLambdas = {
createThingGroup: string
}

export type BifravstLambdas = {
export type AssetTrackerLambdas = {
storeMessagesInTimestream: string
geolocateCellHttpApi: string
invokeStepFunctionFromSQS: string
Expand Down Expand Up @@ -109,8 +109,8 @@ export const prepareCDKLambdas = async ({
)
const cdkLambdaDeps = {
'@aws-sdk/client-iot': dependencies['@aws-sdk/client-iot'],
'@bifravst/cloudformation-helpers':
dependencies['@bifravst/cloudformation-helpers'],
'@nordicsemiconductor/cloudformation-helpers':
dependencies['@nordicsemiconductor/cloudformation-helpers'],
}
if (
Object.values(cdkLambdaDeps).find((v) => v === undefined) !== undefined
Expand Down Expand Up @@ -163,26 +163,26 @@ export const prepareCDKLambdas = async ({
}
}

export const prepareBifravstLambdas = async ({
export const prepareAssetTrackerLambdas = async ({
rootDir,
outDir,
sourceCodeBucketName,
}: {
rootDir: string
outDir: string
sourceCodeBucketName: string
}): Promise<PackedLambdas<BifravstLambdas>> => {
const reporter = ConsoleProgressReporter('Bifravst Lambdas')
}): Promise<PackedLambdas<AssetTrackerLambdas>> => {
const reporter = ConsoleProgressReporter('Asset Tracker Lambdas')
return {
layerZipFileName: await packBaseLayer({
reporter,
srcDir: rootDir,
outDir,
Bucket: sourceCodeBucketName,
}),
lambdas: await packLayeredLambdas<BifravstLambdas>({
lambdas: await packLayeredLambdas<AssetTrackerLambdas>({
reporter,
id: 'bifravst',
id: 'asset-tracker',
mode: WebpackMode.production,
srcDir: rootDir,
outDir,
Expand Down
3 changes: 2 additions & 1 deletion cdk/regions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Note that not all AWS features are available in all AWS regions.
* Here we keep a list of regions that are known to work with Bifravst.
* Here we keep a list of regions that are known to work with the
* Asset Tracker Example.
*/
export const supportedRegions = [
'us-east-1',
Expand Down
6 changes: 3 additions & 3 deletions cdk/resources/CellGeolocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as StepFunctionTasks from '@aws-cdk/aws-stepfunctions-tasks'
import * as Lambda from '@aws-cdk/aws-lambda'
import { logToCloudWatch } from './logToCloudWatch'
import { LambdaLogGroup } from './LambdaLogGroup'
import { BifravstLambdas } from '../prepare-resources'
import { AssetTrackerLambdas } from '../prepare-resources'
import { StateMachineType } from '@aws-cdk/aws-stepfunctions'
import { Role } from '@aws-cdk/aws-iam'
import * as SQS from '@aws-cdk/aws-sqs'
Expand All @@ -30,7 +30,7 @@ export class CellGeolocation extends CloudFormation.Resource {
lambdas,
enableUnwiredApi,
}: {
lambdas: LambdasWithLayer<BifravstLambdas>
lambdas: LambdasWithLayer<AssetTrackerLambdas>
enableUnwiredApi: boolean
},
) {
Expand Down Expand Up @@ -179,7 +179,7 @@ export class CellGeolocation extends CloudFormation.Resource {
new IAM.PolicyStatement({
actions: ['ssm:GetParametersByPath'],
resources: [
`arn:aws:ssm:${parent.region}:${parent.account}:parameter/bifravst/cellGeoLocation/unwiredlabs`,
`arn:aws:ssm:${parent.region}:${parent.account}:parameter/asset-tracker/cellGeoLocation/unwiredlabs`,
],
}),
],
Expand Down
6 changes: 3 additions & 3 deletions cdk/resources/CellGeolocationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as CloudFormation from '@aws-cdk/core'
import * as HttpApi from '@aws-cdk/aws-apigatewayv2'
import * as IAM from '@aws-cdk/aws-iam'
import * as Lambda from '@aws-cdk/aws-lambda'
import { BifravstLambdas } from '../prepare-resources'
import { AssetTrackerLambdas } from '../prepare-resources'
import { logToCloudWatch } from './logToCloudWatch'
import { CellGeolocation } from './CellGeolocation'
import { LambdasWithLayer } from './LambdasWithLayer'
Expand All @@ -27,7 +27,7 @@ export class CellGeolocationApi extends CloudFormation.Resource {
lambdas,
}: {
cellgeo: CellGeolocation
lambdas: LambdasWithLayer<BifravstLambdas>
lambdas: LambdasWithLayer<AssetTrackerLambdas>
},
) {
super(parent, id)
Expand Down Expand Up @@ -186,7 +186,7 @@ export class CellGeolocationApi extends CloudFormation.Resource {
sourceArn: `arn:aws:execute-api:${this.stack.region}:${this.stack.account}:${this.api.ref}/${this.stage.stageName}/POST/cell`,
})

// Add $default route, this is a attempt to fix https://github.com/bifravst/aws/issues/455
// Add $default route, this is a attempt to fix https://github.com/NordicSemiconductor/asset-tracker-cloud-aws-js/issues/455
new HttpApi.CfnRoute(this, 'defaultRoute', {
apiId: this.api.ref,
routeKey: '$default',
Expand Down
4 changes: 2 additions & 2 deletions cdk/resources/HistoricalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Lambda from '@aws-cdk/aws-lambda'
import * as Timestream from '@aws-cdk/aws-timestream'
import { logToCloudWatch } from './logToCloudWatch'
import { LambdaLogGroup } from './LambdaLogGroup'
import { BifravstLambdas } from '../prepare-resources'
import { AssetTrackerLambdas } from '../prepare-resources'
import { LambdasWithLayer } from './LambdasWithLayer'

/**
Expand All @@ -21,7 +21,7 @@ export class HistoricalData extends CloudFormation.Resource {
lambdas,
userRole,
}: {
lambdas: LambdasWithLayer<BifravstLambdas>
lambdas: LambdasWithLayer<AssetTrackerLambdas>
userRole: IAM.IRole
},
) {
Expand Down

0 comments on commit 3a040f8

Please sign in to comment.