Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from troy-ameigh/main
Browse files Browse the repository at this point in the history
updated package versions
  • Loading branch information
troy-ameigh authored Mar 1, 2024
2 parents 1727301 + 3e6aa48 commit 0cf7c00
Show file tree
Hide file tree
Showing 11 changed files with 2,512 additions and 223 deletions.
6 changes: 3 additions & 3 deletions bin/cdk-solution.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as cdk from 'aws-cdk-lib';
import { AwsSolutionsChecks } from 'cdk-nag';

import { MainStack } from '../lib/main';
import { Config } from '../lib/core/config';
import { MainStack } from '../lib/main';

const app = new cdk.App();
cdk.Aspects.of(app).add(new AwsSolutionsChecks({
cdk.Aspects.of(app).add(new AwsSolutionsChecks({
verbose: true,
reports: true
}));
Expand All @@ -21,7 +21,7 @@ async function Main() {
description: '(qs-1u67sa7bo)'
});
});

}

Main();
1 change: 0 additions & 1 deletion docs/deployment_guide/partner_editable/_settings.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@
:deployment_time: 30 minutes
//:default_deployment_region: us-east-1
// :private_repo:

20 changes: 12 additions & 8 deletions lib/core/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import * as fs from 'fs';
import * as yaml from 'js-yaml';
import Ajv from "ajv";
import * as yaml from 'js-yaml';


/**
* Configuration class for the solution.
Expand All @@ -23,7 +25,7 @@ export class Config {

/**
* Constructor to load configuration.
*
*
* @param schemaPath - File path of schema.
*/
constructor(schemaPath?: string) {
Expand All @@ -36,7 +38,7 @@ export class Config {

/**
* Gets the current configuration.
*
*
* @returns The instance of Config.
*/
public static get Current(): Config {
Expand All @@ -45,22 +47,24 @@ export class Config {

/**
* Load the configuration file.
*
*
* @param configPath - The config path.
*/
public async Load(configPath: string) {
public async Load(configPath: string){
// eslint-disable-next-line
let localConfig: any = yaml.load(fs.readFileSync(configPath, "utf8"));
const config = this.validateConfig(localConfig);
this._config = config;
}

/**
* Validate the configuration inputs.
*
*
* @param unparsedConfig - The configuration input.
* @returns - The configuration input.
*/
private validateConfig(unparsedConfig: any): any {
// eslint-disable-next-line
let ajv = new Ajv();
const isValid = ajv.validate(this._schema, unparsedConfig);

Expand All @@ -73,7 +77,7 @@ export class Config {

/**
* Read in property.
*
*
* @param propertyName - Name of the property.
* @returns Property value.
*/
Expand Down Expand Up @@ -173,7 +177,7 @@ interface Instance {
Password: string;
}

/**
/**
* Database properties
*/
interface Database {
Expand Down
3 changes: 2 additions & 1 deletion lib/core/interface/lambda-deployment-stack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cdk from "aws-cdk-lib";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as iam from "aws-cdk-lib/aws-iam";
import * as lambda from "aws-cdk-lib/aws-lambda";


/**
* Interface for the Lambda deployment stacks.
Expand Down
11 changes: 6 additions & 5 deletions lib/data-fabric-security-stack.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NestedStack, RemovalPolicy } from "aws-cdk-lib";
import { Construct } from "constructs";

import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as route53 from "aws-cdk-lib/aws-route53";
import * as logs from "aws-cdk-lib/aws-logs";
import * as route53 from "aws-cdk-lib/aws-route53";
import { Construct } from "constructs";

import { DataFabricSecurityStackProps } from "./props/stack-props";

Expand Down Expand Up @@ -38,7 +38,7 @@ export class DataFabricSecurityStack extends NestedStack {

/**
* Constructor of the Data Fabric Solution stack.
*
*
* @param scope - Parent of this stack.
* @param id - Construct ID of this stack.
* @param props - Properties of this stack.
Expand All @@ -48,7 +48,7 @@ export class DataFabricSecurityStack extends NestedStack {

this.coreId = (id: string) => `${props.prefix}-${id}`;
this.commonName = props.prefix;

// Create a VPC if there was no VPC ID provided.
if(props.vpc.vpcId == "" && !props.vpc.vpcId) {
const cwLogs = new logs.LogGroup(this, 'Log', {
Expand All @@ -57,7 +57,7 @@ export class DataFabricSecurityStack extends NestedStack {
});

this.vpc = new ec2.Vpc(this, this.coreId('vpc'), {
vpcName: this.coreId('vpc'),
vpcName: this.coreId('vpc'),
maxAzs: props.vpc.maxAZs,
flowLogs: {
's3': {
Expand All @@ -74,6 +74,7 @@ export class DataFabricSecurityStack extends NestedStack {
vpcId: props.vpc.vpcId,
isDefault: false,
});
// eslint-disable-next-line
for (let i in props.vpc.subnetIds) {
this.subnets.push(ec2.Subnet.fromSubnetId(this,`subnet${i}` , props.vpc.subnetIds[i]))
}
Expand Down
48 changes: 24 additions & 24 deletions lib/eks-blueprints-stack.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { CfnOutput, Duration, RemovalPolicy } from "aws-cdk-lib";
import { Construct } from "constructs";

import * as eks from 'aws-cdk-lib/aws-eks';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as iam from 'aws-cdk-lib/aws-iam';
import { KubectlV27Layer } from '@aws-cdk/lambda-layer-kubectl-v27';
import * as blueprints from '@aws-quickstart/eks-blueprints';
import { addons } from "@aws-quickstart/eks-blueprints";

import { KubectlV27Layer } from '@aws-cdk/lambda-layer-kubectl-v27';
import { ImportHostedZoneProvider } from "@aws-quickstart/eks-blueprints";
import { CfnOutput, Duration, RemovalPolicy } from "aws-cdk-lib";

import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as eks from 'aws-cdk-lib/aws-eks';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as kms from 'aws-cdk-lib/aws-kms';
import { Construct } from "constructs";

import { CdkNagSuppressions } from "./core/utilities/cdk-nag-suppressions";
import { EksBlueprintsStackProps } from "./props/stack-props";
Expand All @@ -30,14 +30,14 @@ export class EksBlueprintsStack {

/**
* Constructor of the EKS Blueprints stack.
*
*
* @param scope - Parent of this stack.
* @param id - Construct ID of this stack.
* @param props - Properties of this stack.
*/
constructor(scope: Construct, id: string, props: EksBlueprintsStackProps) {
constructor(scope: Construct, id: string, props: EksBlueprintsStackProps) {
this.eksId = (id: string) => `${props.prefix}-${id}`;

// Set EKS endpoint access.
const endpointAccess = props.endpointAccess;
let access;
Expand Down Expand Up @@ -149,7 +149,7 @@ export class EksBlueprintsStack {

/**
* Get the EKS Blueprint.
*
*
* @returns The EKS Blueprint.
*/
public getStack(): blueprints.EksBlueprint {
Expand All @@ -158,7 +158,7 @@ export class EksBlueprintsStack {

/**
* Generate cluster attributes as outputs.
*
*
* @param cluster - The EKS Cluster.
*/
private generateOutputs(cluster : eks.ICluster): void {
Expand All @@ -182,7 +182,7 @@ export class EksBlueprintsStack {
}

/**
* Create cdk-nag suppressions for EKS-related with ServiceRole, DefaultPolicy, or NodeGroupRole.
* Create cdk-nag suppressions for EKS-related with ServiceRole, DefaultPolicy, or NodeGroupRole.
*/
private createEksCdkNagSuppressions() {
for (const child of this.eksBuildStack.node.findAll()) {
Expand All @@ -208,21 +208,21 @@ export class EksBlueprintsStack {
this.createEksCdkNagSuppressions();

CdkNagSuppressions.createStackCdkNagSuppressions(
this.eksBuildStack,
'AwsSolutions-KMS5',
this.eksBuildStack,
'AwsSolutions-KMS5',
'Suppressing and ignoring the initial default KMS key',
);

CdkNagSuppressions.createResourceCdkNagSuppressions(
this.eksBuildStack.getClusterInfo().cluster,
'AwsSolutions-IAM5',
'Suppressing IAM wildcards defined by default when deploying EKS',
this.eksBuildStack.getClusterInfo().cluster,
'AwsSolutions-IAM5',
'Suppressing IAM wildcards defined by default when deploying EKS',
);

CdkNagSuppressions.createResourceCdkNagSuppressions(
this.eksBuildStack.getClusterInfo().cluster,
'AwsSolutions-IAM4',
'Only suppressing required EKS AWS Managed Policies',
this.eksBuildStack.getClusterInfo().cluster,
'AwsSolutions-IAM4',
'Only suppressing required EKS AWS Managed Policies',
);
}

Expand Down
34 changes: 18 additions & 16 deletions lib/immuta-stack.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import * as path from "path";
import * as cdk from 'aws-cdk-lib';
import { Construct } from "constructs";

import * as lambda from "aws-cdk-lib/aws-lambda";
import * as iam from "aws-cdk-lib/aws-iam";
import * as ec2 from "aws-cdk-lib/aws-ec2";
import * as iam from "aws-cdk-lib/aws-iam";
import * as lambda from "aws-cdk-lib/aws-lambda";
import * as cr from "aws-cdk-lib/custom-resources";

import { KubectlLayer } from "aws-cdk-lib/lambda-layer-kubectl";
import { AwsCliLayer } from "aws-cdk-lib/lambda-layer-awscli";
import { KubectlLayer } from "aws-cdk-lib/lambda-layer-kubectl";
import { Construct } from "constructs";

import * as path from "path";

import { ImmutaStackProps } from "./props/stack-props";
import { ILambdaDeploymentStack } from "./core/interface/lambda-deployment-stack";
import { LambdaDeployParameters, LambdaDestroyParameters } from "./core/interface/lambda-deployment-parameters";
import { LambdaDeploymentPolicies } from "./core/utilities/lambda-deployment-policies";
import { ILambdaDeploymentStack } from "./core/interface/lambda-deployment-stack";
import { CdkNagSuppressions } from "./core/utilities/cdk-nag-suppressions";
import { LambdaDeploymentPolicies } from "./core/utilities/lambda-deployment-policies";
import { ImmutaStackProps } from "./props/stack-props";

/**
* Immuta stack.
Expand All @@ -25,7 +24,7 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta
* Stack identifier.
*/
private readonly immutaId: any;

/**
* Lambda function install name.
*/
Expand Down Expand Up @@ -73,7 +72,7 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Constructor of the Immuta stack.
*
*
* @param scope - Parent of this stack.
* @param id - Construct ID of this stack.
* @param props - Properties of this stack.
Expand Down Expand Up @@ -101,11 +100,12 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Creates the policy for the Lambda function to install Immuta.
*
*
* @param props - Properties of the stack.
* @returns The policy document.
*/
createDeployPolicy(props: ImmutaStackProps): iam.PolicyDocument {
// eslint-disable-next-line
let deployParameters: LambdaDeployParameters = {
resourceName: this.immutaId('deploy-policy'),
clusterResources: [props.cluster.clusterArn],
Expand All @@ -121,11 +121,12 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Creates the policy for the Lambda function to uninstall Immuta.
*
*
* @param props - Properties of the stack.
* @returns The policy document.
*/
createDestroyPolicy(props: ImmutaStackProps): iam.PolicyDocument {
// eslint-disable-next-line
let destroyParameters: LambdaDestroyParameters = {
resourceName: this.immutaId('destroy-policy'),
clusterResources: [props.cluster.clusterArn],
Expand All @@ -144,7 +145,7 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Creates the Lambda function to install Immuta.
*
*
* @param props - Properties of the stack.
* @returns The Lambda function.
*/
Expand Down Expand Up @@ -197,7 +198,7 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Creates the Lambda function to uninstall Immuta.
*
*
* @param props - Properties of the stack.
* @returns The Lambda function.
*/
Expand Down Expand Up @@ -238,11 +239,12 @@ export class ImmutaStack extends cdk.NestedStack implements ILambdaDeploymentSta

/**
* Creates the custom resource to respond to stack changes (create and delete events) by invoking Lambda functions.
*
*
* @param deployFunction - Lambda function to install.
* @param destroyFunction - Lambda function to uninstall.
*/
createBootstrap(deployFunction: lambda.Function, destroyFunction: lambda.Function): void {
// eslint-disable-next-line
let bootstrapRole = new iam.Role(this, this.immutaId('bootstrap-role'), {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
Expand Down
Loading

0 comments on commit 0cf7c00

Please sign in to comment.