Skip to content

Commit 2d1e525

Browse files
authored
Merge pull request #16 from aws-observability/fix/linter
Adding GH Actions and fixing linter
2 parents 85b9e88 + d5be998 commit 2d1e525

File tree

10 files changed

+162
-27
lines changed

10 files changed

+162
-27
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module.exports = {
1212
"@typescript-eslint/no-explicit-any": "off",
1313
"@typescript-eslint/explicit-module-boundary-types": "off",
1414
"@typescript-eslint/no-non-null-assertion": "off",
15-
"prefer-const": "off"
15+
"@typescript-eslint/no-unused-vars": [1, {"argsIgnorePattern": "^_"}],
16+
indent: ['error', 4],
17+
"prefer-const": "off",
18+
"semi": ['error',"always"],
1619
},
1720
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. Go to '...'
13+
2. Click on '....'
14+
3. Scroll down to '....'
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Screenshots**
21+
If applicable, add screenshots to help explain your problem.
22+
23+
**Desktop (please complete the following information):**
24+
- OS: [e.g. iOS]
25+
- Browser [e.g. chrome, safari]
26+
- Version [e.g. 22]
27+
28+
**Smartphone (please complete the following information):**
29+
- Device: [e.g. iPhone6]
30+
- OS: [e.g. iOS8.1]
31+
- Browser [e.g. stock browser, safari]
32+
- Version [e.g. 22]
33+
34+
**Additional context**
35+
Add any other context about the problem here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*Issue #, if available:*
2+
3+
*Description of changes:*
4+
5+
6+
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.github/workflows/ci.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Node.js CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: macos-12
12+
13+
strategy:
14+
matrix:
15+
node-version: [18]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v1
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Cache node modules
26+
uses: actions/cache@v2
27+
env:
28+
cache-name: cache-node-modules
29+
with:
30+
# npm cache files are stored in `~/.npm` on Linux/macOS
31+
path: ~/.npm
32+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-build-${{ env.cache-name }}-
35+
${{ runner.os }}-build-
36+
${{ runner.os }}-
37+
38+
- name: Install Deps
39+
run: make deps
40+
41+
- name: Run Linter
42+
run: make lint
43+
44+
- name: Build TSC
45+
run: make build
46+
47+
- name: Run CDK List
48+
run: make list
49+
50+
- name: Run CDK Synth
51+
run: make test-all

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ TSC := node node_modules/.bin/tsc
55
ESLINT := node node_modules/.bin/eslint
66
CDK := node node_modules/.bin/cdk
77
pattern: pattern_name := $(firstword $(filter-out pattern, $(MAKECMDGOALS)))
8-
pattern: pattern_command := $(filter-out pattern $(pattern_name), $(MAKECMDGOALS))
8+
pattern: pattern_command := $(subst pattern $(pattern_name), , $(MAKECMDGOALS))
99

1010
pattern_files := $(notdir $(wildcard bin/*.ts))
1111
formatted_pattern_names := $(patsubst %.ts,%,$(pattern_files))
@@ -20,6 +20,9 @@ deps: bootstrap
2020
lint:
2121
$(ESLINT) . --ext .js,.jsx,.ts,.tsx
2222

23+
lint-fix:
24+
$(ESLINT) . --ext .js,.jsx,.ts,.tsx --fix
25+
2326
build:
2427
rm -rf dist && $(TSC) --skipLibCheck
2528

@@ -28,7 +31,7 @@ compile:
2831

2932
list:
3033
@$ echo "To work with patterns use: \n\t$$ make pattern <pattern-name> <list | deploy | synth | destroy>"
31-
@$ echo "Example:\n\t$$ make pattern single-new-eks-cluster-opensource deploy \n\nPatterns: \n"
34+
@$ echo "Example:\n\t$$ make pattern fargate deploy \n\nPatterns: \n"
3235
@$ $(foreach pattern, $(formatted_pattern_names), echo "\t$(pattern)";)
3336

3437
mkdocs:

docs/patterns/single-new-eks-observability-accelerators/single-new-eks-opensource-observability.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ please read the [service documentation](https://docs.aws.amazon.com/eks/latest/u
1818
- AWS Distro For OpenTelemetry Operator and Collector for Metrics and Traces
1919
- Logs with [AWS for FluentBit](https://github.com/aws/aws-for-fluent-bit)
2020
- Installs Grafana Operator to add AWS data sources and create Grafana Dashboards to Amazon Managed Grafana.
21-
- Installs FluxCD to perform GitOps sync of a Git Repo to EKS Cluster. We will use this later for creating Grafana Dashboards and AWS datasources to Amazon Managed Grafana.
21+
- Installs FluxCD to perform GitOps sync of a Git Repo to EKS Cluster. We will use this later for creating Grafana Dashboards and AWS datasources to Amazon Managed Grafana. You can also use your own GitRepo to sync your own Grafana resources such as Dashboards, Datasources etc. Please check our One observability module - [GitOps with Amazon Managed Grafana](https://catalog.workshops.aws/observability/en-US/aws-managed-oss/gitops-with-amg) to learn more about this.
2222
- Installs External Secrets Operator to retrieve and Sync the Grafana API keys.
2323
- Amazon Managed Grafana Dashboard and data source
2424
- Alerts and recording rules with AWS Managed Service for Prometheus
@@ -57,6 +57,9 @@ export COA_AMG_WORKSPACE_ID=g-xxx
5757
export COA_AMG_ENDPOINT_URL=https://g-xyz.grafana-workspace.us-east-1.amazonaws.com
5858
```
5959

60+
!!! warning
61+
Setting up environment variables `COA_AMG_ENDPOINT_URL` and `AWS_REGION` is mandatory for successful execution of this pattern.
62+
6063
4. GRAFANA API KEY: Amazon Managed Grafana provides a control plane API for generating Grafana API keys.
6164

6265
```bash
@@ -79,9 +82,24 @@ aws secretsmanager update-secret \
7982
--region $AWS_REGION
8083
```
8184

82-
6. Install project dependencies by running `npm install` in the main folder of this cloned repository
85+
6. Install project dependencies by running `npm install` in the main folder of this cloned repository.
86+
87+
7. The actual settings for the hosted zone name and expected subzone name are expected to be specified in the CDK context. Generically it is inside the cdk.context.json file of the current directory or in `~/.cdk.json` in your home directory.
88+
89+
Example settings: Update the context in `cdk.json` file located in `cdk-eks-blueprints-patterns` directory
90+
91+
```
92+
"context": {
93+
"cluster.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/cluster.json",
94+
"kubelet.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/kubelet.json",
95+
"namespaceworkloads.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/namespace-workloads.json",
96+
"nodexporter.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodeexporter-nodes.json",
97+
"nodes.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodes.json",
98+
"workloads.dashboard.url": "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/workloads.json"
99+
}
100+
```
83101

84-
7. Once all pre-requisites are set you are ready to deploy the pipeline. Run the following command from the root of this repository to deploy the pipeline stack:
102+
8. Once all pre-requisites are set you are ready to deploy the pipeline. Run the following command from the root of this repository to deploy the pipeline stack:
85103

86104
```bash
87105
make build

lib/single-new-eks-opensource-observability-construct/grafanaoperatorsecretaddon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class GrafanaOperatorSecretAddon implements blueprints.ClusterAddOn {
4848
metadata: {
4949
name: "external-grafana-admin-credentials",
5050
namespace: "grafana-operator"
51-
},
51+
},
5252
spec: {
5353
secretStoreRef: {
5454
name: "secret-manager-store",

lib/single-new-eks-opensource-observability-construct/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@ import { EksBlueprint, utils } from '@aws-quickstart/eks-blueprints';
33
import * as blueprints from '@aws-quickstart/eks-blueprints';
44
import { GrafanaOperatorSecretAddon } from './grafanaoperatorsecretaddon';
55
import * as amp from 'aws-cdk-lib/aws-aps';
6-
const assert = require('assert').strict
6+
import * as assert from "assert";
77

88
export default class SingleNewEksOpenSourceobservabilityConstruct {
99
constructor(scope: Construct, id: string) {
1010
// AddOns for the cluster
1111
const stackId = `${id}-observability-accelerator`;
1212
// All Grafana Dashboard Default URLs
13-
const clusterDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/cluster.json"
14-
const kubeletDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/kubelet.json"
15-
const namespaceWorkloadsDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/namespace-workloads.json"
16-
const nodeExporterDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodeexporter-nodes.json"
17-
const nodesDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodes.json"
18-
const workloadsDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/workloads.json"
13+
const clusterDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/cluster.json";
14+
const kubeletDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/kubelet.json";
15+
const namespaceWorkloadsDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/namespace-workloads.json";
16+
const nodeExporterDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodeexporter-nodes.json";
17+
const nodesDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/nodes.json";
18+
const workloadsDefaultDashUrl = "https://raw.githubusercontent.com/aws-observability/aws-observability-accelerator/main/artifacts/grafana-dashboards/eks/infrastructure/workloads.json";
1919

2020
const account = process.env.COA_ACCOUNT_ID! || process.env.CDK_DEFAULT_ACCOUNT!;
2121
const region = process.env.COA_AWS_REGION! || process.env.CDK_DEFAULT_REGION!;
2222
const ampWorkspaceName = process.env.COA_AMP_WORKSPACE_NAME! || 'observability-amp-Workspace';
2323
const ampPrometheusEndpoint = (blueprints.getNamedResource(ampWorkspaceName) as unknown as amp.CfnWorkspace).attrPrometheusEndpoint;
2424

2525
const amgEndpointUrl = process.env.COA_AMG_ENDPOINT_URL;
26-
assert.ok(amgEndpointUrl, 'The "COA_AMG_ENDPOINT_URL" environment variable needs to be populated with AMG URL Endpoint');
2726

2827
// All Grafana Dashboard URLs from `cdk.json` if present
2928
const clusterDashUrl: string = utils.valueFromContext(scope, "cluster.dashboard.url", clusterDefaultDashUrl);

package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,28 @@
1212
"lint": "npx eslint . --ext .js,.jsx,.ts,.tsx"
1313
},
1414
"devDependencies": {
15-
"@aws-quickstart/eks-blueprints": "^1.9.0",
16-
"@types/jest": "^29.4.0",
17-
"@types/node": "^18.11.9",
18-
"@types/source-map-support": "^0.5.6",
15+
"@aws-quickstart/eks-blueprints": "^1.9.1",
16+
"@types/jest": "^29.5.1",
17+
"@types/node": "^18.15.12",
18+
"@typescript-eslint/eslint-plugin": "^5.59.0",
19+
"@typescript-eslint/parser": "^5.59.0",
1920
"copyfiles": "^2.4.1",
20-
"eslint": "^8.26.0",
21-
"jest": "^29.2.2",
22-
"ts-jest": "^29.0.3",
21+
"eslint": "^8.38.0",
22+
"jest": "^29.5.0",
23+
"ts-jest": "^29.1.0",
2324
"ts-node": "^10.9.1",
24-
"typescript": "~4.8.4"
25+
"typescript": "^5.0.4"
2526
},
2627
"dependencies": {
27-
"@aws-quickstart/eks-blueprints": "^1.9.0",
28-
"aws-cdk": "^2.81.0",
28+
"@aws-quickstart/eks-blueprints": "^1.9.1",
2929
"constructs": "^10.0.0",
30+
"aws-cdk": "2.83.1",
31+
"eks-blueprints-cdk-kubeflow-ext": "0.1.9",
3032
"source-map-support": "^0.5.21"
3133
},
3234
"overrides": {
33-
"@aws-quickstart/eks-blueprints": "^1.9.0",
34-
"aws-cdk": "^2.81.0"
35+
"@aws-quickstart/eks-blueprints": "^1.9.1",
36+
"aws-cdk": "2.83.1",
37+
"xml2js": "0.5.0"
3538
}
3639
}

0 commit comments

Comments
 (0)