Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zilla Plus for Amazon MSK Web Streaming AWS CDK template #39

Merged
merged 20 commits into from
Jan 23, 2025
Merged
16 changes: 11 additions & 5 deletions amazon-msk/cdk/secure-public-access/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,18 @@ Note down the ARN of the ACM Private Certificate Authority you want to use.
"cloudwatch":
{
"disable": false,
"logGroupName": "<your public tls certificate key ARN>",
"port": "<your public port>"
"logs":
{
"group": "<your cloudwatch log group name>"
},
"metrics":
{
"namespace": "<your cloudwatch metrics namespace>"
}
}
```

By default CloudWatch metrics and logging is enabled. To disable CloudWatch logging and metrics, set the `cloudwatchDisabled` context variable to `true`.
By default CloudWatch metrics and logging is enabled. To disable CloudWatch logging and metrics, set the `cloudwatch.disabled` context variable to `true`.

You can create or use existing log groups and metric namespaces in CloudWatch.

Expand All @@ -207,15 +213,15 @@ aws logs describe-log-groups --query 'logGroups[*].[logGroupName]' --output tabl
```

This command will return a table listing the names of all the log groups in your CloudWatch.
In your `cdk.json` file add the desired CloudWatch Logs Group for variable name `logGroupName` under `zilla-plus` object in the `cloudwatch` variables section.
In your `cdk.json` file add the desired CloudWatch Logs Group for variable name `logs.group` under `zilla-plus` object in the `cloudwatch` variables section.

#### List All CloudWatch Custom Metric Namespaces

```bash
aws cloudwatch list-metrics --query 'Metrics[*].Namespace' --output text | tr '\t' '\n' | sort | uniq | grep -v '^AWS'
```

In your `cdk.json` file add the desired CloudWatch Metrics Namespace for variable name `metricsNamespace` under `zilla-plus` object in the `cloudwatch` variables section.
In your `cdk.json` file add the desired CloudWatch Metrics Namespace for variable name `metrics.namespace` under `zilla-plus` object in the `cloudwatch` variables section.

### Enable SSH Access

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ systemctl start nitro-enclaves-acm.service
}

const cloudwatch = zillaPlusContext.cloudwatch;
const cloudwatchDisabled = cloudwatch.disabled ?? false;
const cloudwatchDisabled = cloudwatch?.disabled ?? false;

if (!cloudwatchDisabled) {
const defaultLogGroupName = `${id}-group`;
const defaultMetricNamespace = `${id}-namespace`;

const logGroupName = cloudwatch.logGroupName ?? defaultLogGroupName;
const metricNamespace = cloudwatch.metricsNamespace ?? defaultMetricNamespace;
const logGroupName = cloudwatch?.logs?.group ?? defaultLogGroupName;
const metricNamespace = cloudwatch?.metrics?.namespace ?? defaultMetricNamespace;

const cloudWatchLogGroup = new logs.LogGroup(this, `LogGroup-${id}`, {
logGroupName: logGroupName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,22 @@ test('Secure Public Access Stack created', () => {
]
}
]
},
"vpcId": "vpc-12345",
"mskBootstrapServers": "b-1.mymskcluster.****.us-east-1.amazonaws.com:9096",
"mskClientAuthentication": "SASL/SCRAM",
"mskCertificateAuthorityArn": "arn:aws:acm-pca:us-east-1:****:certificate-authority/*********",
"publicWildcardDNS": "*.example.aklivity.io",
"publicTlsCertificateKey": "arn:aws:acm:us-east-1:****:certificate//*********",
},
"zilla-plus":
{
"vpcId": "vpc-12345",
"msk":
{
"bootstrapServers": "b-1.mymskcluster.****.us-east-1.amazonaws.com:9096",
"clientAuthentication": "SASL/SCRAM",
"certificateAuthorityArn": "arn:aws:acm-pca:us-east-1:****:certificate-authority/*********",
},
"public":
{
"wildcardDNS": "*.example.aklivity.io",
"tlsCertificateKey": "arn:aws:acm:us-east-1:****:certificate//*********"
}
}
}
}
);
Expand Down
16 changes: 11 additions & 5 deletions amazon-msk/cdk/web-streaming/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,18 @@ Note down the security group IDs (GroupId) of the desired security groups.
"cloudwatch":
{
"disable": false,
"logGroupName": "<your public tls certificate key ARN>",
"port": "<your public port>"
"logs":
{
"group": "<your cloudwatch log group name>"
},
"metrics":
{
"namespace": "<your cloudwatch metrics namespace>"
}
}
```

By default CloudWatch metrics and logging is enabled. To disable CloudWatch logging and metrics, set the `cloudwatchDisabled` context variable to `true`.
By default CloudWatch metrics and logging is enabled. To disable CloudWatch logging and metrics, set the `cloudwatch.disabled` context variable to `true`.

You can create or use existing log groups and metric namespaces in CloudWatch.

Expand All @@ -172,15 +178,15 @@ aws logs describe-log-groups --query 'logGroups[*].[logGroupName]' --output tabl
```

This command will return a table listing the names of all the log groups in your CloudWatch.
In your `cdk.json` file add the desired CloudWatch Logs Group for variable name `logGroupName` under `zilla-plus` object in the `cloudwatch` variables section.
In your `cdk.json` file add the desired CloudWatch Logs Group for variable name `logs.group` under `zilla-plus` object in the `cloudwatch` variables section.

#### List All CloudWatch Custom Metric Namespaces

```bash
aws cloudwatch list-metrics --query 'Metrics[*].Namespace' --output text | tr '\t' '\n' | sort | uniq | grep -v '^AWS'
```

In your `cdk.json` file add the desired CloudWatch Metrics Namespace for variable name `metricsNamespace` under `zilla-plus` object in the `cloudwatch` variables section.
In your `cdk.json` file add the desired CloudWatch Metrics Namespace for variable name `metrics.namespace` under `zilla-plus` object in the `cloudwatch` variables section.

### Enable JWT Access Tokens

Expand Down
6 changes: 3 additions & 3 deletions amazon-msk/cdk/web-streaming/lib/web-streaming-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ export class WebStreamingStack extends cdk.Stack {
}

const cloudwatch = zillaPlusContext.cloudwatch;
const cloudwatchDisabled = cloudwatch.disabled ?? false;
const cloudwatchDisabled = cloudwatch?.disabled ?? false;

if (!cloudwatchDisabled) {
const defaultLogGroupName = `${id}-group`;
const defaultMetricNamespace = `${id}-namespace`;

const logGroupName = cloudwatch.logGroupName ?? defaultLogGroupName;
const metricNamespace = cloudwatch.metricsNamespace ?? defaultMetricNamespace;
const logGroupName = cloudwatch?.logs?.group ?? defaultLogGroupName;
const metricNamespace = cloudwatch?.metrics?.namespace ?? defaultMetricNamespace;

const cloudWatchLogGroup = new logs.LogGroup(this, `LogGroup-${id}`, {
logGroupName: logGroupName,
Expand Down
21 changes: 12 additions & 9 deletions amazon-msk/cdk/web-streaming/test/web-streaming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ test('Secure Public Access Stack created', () => {
]
}
]
},
"vpcId": "vpc-12345",
"msk":
{
"bootstrapServers": "b-1.mymskcluter.****.us-east-1.amazonaws.com:9096",
"credentialsSecretName": "AmazonMSK_Alice"
},
"publicTlsCertificateKey": "arn:aws:acm:us-east-1:****:certificate//*********",
"kafkaTopic": "pets",
},
"zilla-plus":
{
"vpcId": "vpc-12345",
"msk":
{
"bootstrapServers": "b-1.mymskcluter.****.us-east-1.amazonaws.com:9096",
"credentialsSecretName": "AmazonMSK_Alice"
},
"publicTlsCertificateKey": "arn:aws:acm:us-east-1:****:certificate//*********",
"kafkaTopic": "pets",
bmaidics marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
);
Expand Down