Skip to content

Commit

Permalink
Merge pull request #99 from aws-samples/task/lint-rules
Browse files Browse the repository at this point in the history
defined new rules and formatting changes
  • Loading branch information
elamaran11 authored Jun 16, 2023
2 parents 559eecb + f0796fd commit 8ee5823
Show file tree
Hide file tree
Showing 39 changed files with 517 additions and 501 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ module.exports = {
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended'
],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [1, {"argsIgnorePattern": "^_"}],
indent: ['error', 4],
"prefer-const": "off",
"semi": [1,"always"]
"semi": ['error',"always"],
},
};
17 changes: 14 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ To send us a pull request, please:
1. Fork the repository.
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
3. Ensure local tests pass.
4. Commit to your fork using clear commit messages.
5. Send us a pull request, answering any default questions in the pull request interface.
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
4. Ensure the following commands pass:

```
make build
make lint # no errors / warnings, also you can use make lint-fix to fix issues
make pattern <your-pattern> list
make pattern <your-pattern> deploy
```

The above should produce no errors.

5. Commit to your fork using clear commit messages.
6. Send us a pull request, answering any default questions in the pull request interface.
7. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
[creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ await prevalidateSecrets(NginxIngressConstruct.name, undefined, SECRET_ARGO_ADMI
await prevalidateSecrets("my-pattern-name", 'us-east-1', 'my-secret-name'); //
```

## Contributing

See [Contributing](CONTRIBUTING.md) guide for requirements on contribution.

# Deploying Blueprints with External Dependency on AWS Resources

There are cases when the blueprints defined in the patterns have dependencies on existing AWS Resources such as Secrets defined in the account/region.
Expand Down
6 changes: 3 additions & 3 deletions lib/aws-batch-on-eks-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import { BatchEksTeam } from '@aws-quickstart/eks-blueprints';
import { PolicyStatement, Effect } from 'aws-cdk-lib/aws-iam';

Expand All @@ -19,8 +19,8 @@ export default class BatchOnEKSConstruct {
"logs:CreateLogGroup"
],
resources: ["*"],
})
const stackID = `${id}-blueprint`
});
const stackID = `${id}-blueprint`;
blueprints.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT!)
.region(process.env.CDK_DEFAULT_REGION!)
Expand Down
4 changes: 2 additions & 2 deletions lib/bottlerocket-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as eks from 'aws-cdk-lib/aws-eks';
import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as team from '../teams'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import * as team from '../teams';

/**
* Bottlerocket pattern shows how to specify the OS for the node group
Expand Down
10 changes: 5 additions & 5 deletions lib/custom-networking-ipv4-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import * as ec2 from "aws-cdk-lib/aws-ec2";
import { KubernetesVersion, NodegroupAmiType } from 'aws-cdk-lib/aws-eks';
import * as eks from "aws-cdk-lib/aws-eks";
Expand All @@ -20,7 +20,7 @@ export default class CustomNetworkingIPv4Construct {
};


const clusterProvider = new blueprints.MngClusterProvider(mngProps)
const clusterProvider = new blueprints.MngClusterProvider(mngProps);

blueprints.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT!)
Expand All @@ -36,9 +36,9 @@ export default class CustomNetworkingIPv4Construct {
awsVpcK8sCniCustomNetworkCfg: true,
eniConfigLabelDef: 'topology.kubernetes.io/zone'
}),
new blueprints.AwsLoadBalancerControllerAddOn(),
new blueprints.CoreDnsAddOn(),
new blueprints.KubeProxyAddOn(),
new blueprints.AwsLoadBalancerControllerAddOn(),
new blueprints.CoreDnsAddOn(),
new blueprints.KubeProxyAddOn(),
)
.resourceProvider(blueprints.GlobalResources.Vpc, new blueprints.VpcProvider(undefined, {
primaryCidr: "10.2.0.0/16",
Expand Down
4 changes: 2 additions & 2 deletions lib/datadog-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import { DatadogAddOn } from '@datadog/datadog-eks-blueprints-addon';
import { prevalidateSecrets } from '../common/construct-utils';

Expand All @@ -11,7 +11,7 @@ export default class DatadogConstruct {

await prevalidateSecrets(DatadogConstruct.name, process.env.CDK_DEFAULT_REGION!, SECRET_API_KEY);

const stackID = `${id}-blueprint`
const stackID = `${id}-blueprint`;

const addOns: Array<blueprints.ClusterAddOn> = [
new DatadogAddOn({
Expand Down
2 changes: 1 addition & 1 deletion lib/dynatrace-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class DynatraceOperatorConstruct {
const DynatraceOperator = new DynatraceAddOn({
// Setup ssmSecret dynatrace-tokens described here (https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon#aws-secret-manager-secrets)
ssmSecretName: 'dynatrace-tokens'
})
});

EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT!)
Expand Down
10 changes: 5 additions & 5 deletions lib/fargate-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Construct } from 'constructs';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as team from '../teams'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import * as team from '../teams';

/**
* Demonstrates how to use Fargate cluster provider.
Expand All @@ -11,14 +11,14 @@ import * as team from '../teams'
export default class FargateConstruct {
constructor(scope: Construct, id: string) {
// Setup platform team
const accountID = process.env.CDK_DEFAULT_ACCOUNT!
const platformTeam = new team.TeamPlatform(accountID)
const accountID = process.env.CDK_DEFAULT_ACCOUNT!;
const platformTeam = new team.TeamPlatform(accountID);

const fargateProfiles: Map<string, eks.FargateProfileOptions> = new Map([
["team1", { selectors: [{ namespace: "team1" }] }]
]);

const stackID = `${id}-blueprint`
const stackID = `${id}-blueprint`;
const clusterProvider = new blueprints.FargateClusterProvider({
fargateProfiles,
version: eks.KubernetesVersion.V1_25
Expand Down
4 changes: 2 additions & 2 deletions lib/generic-cluster-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as eks from 'aws-cdk-lib/aws-eks';

// Blueprints Lib
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as blueprints from '@aws-quickstart/eks-blueprints';

// Team implementations
import * as team from '../teams'
import * as team from '../teams';

/**
* Demonstrates how to leverage more than one node group along with Fargate profiles.
Expand Down
84 changes: 42 additions & 42 deletions lib/instana-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,63 @@ import * as cdk from "aws-cdk-lib";
import { InstanaOperatorAddon } from "@instana/aws-eks-blueprint-addon";

const instanaProps = {
zone: {
name: process.env.INSTANA_ZONE_NAME, // Mandatory Parameter
},
cluster: {
name: process.env.AMAZON_EKS_CLUSTER_NAME, // Mandatory Parameter
},
agent: {
key: process.env.INSTANA_AGENT_KEY,// Mandatory Parameter
endpointHost: process.env.INSTANA_ENDPOINT_HOST_URL,// Mandatory Parameter
endpointPort: process.env.INSTANA_ENDPOINT_HOST_PORT, // Mandatory Parameter
env: {
zone: {
name: process.env.INSTANA_ZONE_NAME, // Mandatory Parameter
},
cluster: {
name: process.env.AMAZON_EKS_CLUSTER_NAME, // Mandatory Parameter
},
agent: {
key: process.env.INSTANA_AGENT_KEY,// Mandatory Parameter
endpointHost: process.env.INSTANA_ENDPOINT_HOST_URL,// Mandatory Parameter
endpointPort: process.env.INSTANA_ENDPOINT_HOST_PORT, // Mandatory Parameter
env: {
},
},
},
};
const yamlObject = loadYaml(JSON.stringify(instanaProps));

export default class InstanaConstruct {
async buildAsync(scope: cdk.App) {
try {
checkInstanaProps(instanaProps); // Call the function to check prop values
async buildAsync(scope: cdk.App) {
try {
checkInstanaProps(instanaProps); // Call the function to check prop values

const stackID = yamlObject.cluster.name!;
const stackID = yamlObject.cluster.name!;

const addOns: Array<blueprints.ClusterAddOn> = [
new InstanaOperatorAddon(yamlObject),
];
const addOns: Array<blueprints.ClusterAddOn> = [
new InstanaOperatorAddon(yamlObject),
];

blueprints.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT!)
.region(process.env.CDK_DEFAULT_REGION!)
.addOns(...addOns)
.name(stackID)
.build(scope, stackID);
blueprints.EksBlueprint.builder()
.account(process.env.CDK_DEFAULT_ACCOUNT!)
.region(process.env.CDK_DEFAULT_REGION!)
.addOns(...addOns)
.name(stackID)
.build(scope, stackID);

console.log("Blueprint built successfully.");
} catch (error) {
console.error("Error:", error);
throw new Error(`environment variables must be setup for the instana-operator pattern to work`);
console.log("Blueprint built successfully.");
} catch (error) {
console.error("Error:", error);
throw new Error(`environment variables must be setup for the instana-operator pattern to work`);
}
}
}
}

function checkInstanaProps(instanaProps: any) {
function checkPropValue(propName: string, propValue: any) {
if (propValue === undefined || propValue === null || propValue === "") {
throw new Error(`Missing or empty value for property '${propName}'.`);
function checkPropValue(propName: string, propValue: any) {
if (propValue === undefined || propValue === null || propValue === "") {
throw new Error(`Missing or empty value for property '${propName}'.`);
}
}
}

// Check zone
checkPropValue("zone.name", instanaProps.zone.name);
// Check zone
checkPropValue("zone.name", instanaProps.zone.name);

// Check cluster
checkPropValue("cluster.name", instanaProps.cluster.name);
// Check cluster
checkPropValue("cluster.name", instanaProps.cluster.name);

// Check agent
checkPropValue("agent.key", instanaProps.agent.key);
checkPropValue("agent.endpointHost", instanaProps.agent.endpointHost);
checkPropValue("agent.endpointPort", instanaProps.agent.endpointPort);
// Check agent
checkPropValue("agent.key", instanaProps.agent.key);
checkPropValue("agent.endpointHost", instanaProps.agent.endpointHost);
checkPropValue("agent.endpointPort", instanaProps.agent.endpointPort);
}
8 changes: 4 additions & 4 deletions lib/kubeflow-construct/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints'
import * as blueprints from '@aws-quickstart/eks-blueprints';
import { KubeflowAddOn } from 'eks-blueprints-cdk-kubeflow-ext';
import * as amp from 'aws-cdk-lib/aws-aps';

Expand All @@ -16,7 +16,7 @@ export default class KubeflowConstruct {
.region(process.env.CDK_DEFAULT_REGION)
.resourceProvider(ampWorkspaceName, new blueprints.CreateAmpProvider(ampWorkspaceName, ampWorkspaceName))
.addOns( new blueprints.MetricsServerAddOn(),
new blueprints.AwsLoadBalancerControllerAddOn(),
new blueprints.AwsLoadBalancerControllerAddOn(),
new blueprints.ClusterAutoScalerAddOn(),
new blueprints.VpcCniAddOn(),
new blueprints.CoreDnsAddOn(),
Expand All @@ -30,8 +30,8 @@ export default class KubeflowConstruct {
ampPrometheusEndpoint: ampPrometheusEndpoint,
}),
new KubeflowAddOn({
namespace: 'kubeflow-pipelines'
})
namespace: 'kubeflow-pipelines'
})
)
.teams()// add teams here)
.build(scope, stackId);
Expand Down
2 changes: 1 addition & 1 deletion lib/multi-account-monitoring/amg-iam-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class AmgIamSetupStack extends cdk.Stack {
"sts:AssumeRole"
],
resources: [`arn:aws:iam::${props.accounts[i]}:role/ampPrometheusDataSourceRole`,
`arn:aws:iam::${props.accounts[i]}:role/cloudwatchDataSourceRole`
`arn:aws:iam::${props.accounts[i]}:role/cloudwatchDataSourceRole`
],
}));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/multi-account-monitoring/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export class PipelineMultiEnvMonitoring {
async buildAsync(scope: Construct) {
const context = await populateAccountWithContextDefaults();
// environments IDs consts
const PROD1_ENV_ID = `eks-prod1-${context.prodEnv1.region}`
const PROD2_ENV_ID = `eks-prod2-${context.prodEnv2.region}`
const MON_ENV_ID = `central-monitoring-${context.monitoringEnv.region}`
const PROD1_ENV_ID = `eks-prod1-${context.prodEnv1.region}`;
const PROD2_ENV_ID = `eks-prod2-${context.prodEnv2.region}`;
const MON_ENV_ID = `central-monitoring-${context.monitoringEnv.region}`;

const blueprintAmp = new AmpMonitoringConstruct().create(scope, context.prodEnv1.account, context.prodEnv1.region);
const blueprintCloudWatch = new CloudWatchMonitoringConstruct().create(scope, context.prodEnv2.account, context.prodEnv2.region);
Expand Down Expand Up @@ -154,5 +154,5 @@ function createArgoAddonConfig(environment: string, repoUrl: string): blueprints
},
},
}
)
);
}
6 changes: 3 additions & 3 deletions lib/multi-region-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Construct } from 'constructs';

// Team implementations
import * as team from '../teams';
const burnhamManifestDir = './lib/teams/team-burnham/'
const rikerManifestDir = './lib/teams/team-riker/'
const teamManifestDirList = [burnhamManifestDir,rikerManifestDir]
const burnhamManifestDir = './lib/teams/team-burnham/';
const rikerManifestDir = './lib/teams/team-riker/';
const teamManifestDirList = [burnhamManifestDir,rikerManifestDir];

export const SECRET_GIT_SSH_KEY = 'github-ssh-key';
export const SECRET_ARGO_ADMIN_PWD = 'argo-admin-secret';
Expand Down
14 changes: 7 additions & 7 deletions lib/multi-team-construct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { Construct } from 'constructs';
import * as blueprints from '@aws-quickstart/eks-blueprints';

// Team implementations
import * as team from '../teams'
const burnhamManifestDir = './lib/teams/team-burnham/'
const rikerManifestDir = './lib/teams/team-riker/'
const teamManifestDirList = [burnhamManifestDir,rikerManifestDir]
import * as team from '../teams';
const burnhamManifestDir = './lib/teams/team-burnham/';
const rikerManifestDir = './lib/teams/team-riker/';
const teamManifestDirList = [burnhamManifestDir,rikerManifestDir];

export default class MultiTeamConstruct {
constructor(scope: Construct, id: string) {

// Setup platform team
const accountID = process.env.CDK_DEFAULT_ACCOUNT!
const platformTeam = new team.TeamPlatform(accountID)
const accountID = process.env.CDK_DEFAULT_ACCOUNT!;
const platformTeam = new team.TeamPlatform(accountID);

// Teams for the cluster.
const teams: Array<blueprints.Team> = [
Expand All @@ -39,7 +39,7 @@ export default class MultiTeamConstruct {
new blueprints.SecretsStoreAddOn
];

const stackID = `${id}-blueprint`
const stackID = `${id}-blueprint`;
new blueprints.EksBlueprint(scope, { id: stackID, addOns, teams }, {
env: {
region: 'us-east-2',
Expand Down
Loading

0 comments on commit 8ee5823

Please sign in to comment.