Skip to content

Commit

Permalink
Merge pull request #144 from Brandon-Kimberly/main
Browse files Browse the repository at this point in the history
Add tagging AMP workspaces to EKS sol
  • Loading branch information
mhausenblas committed Jun 20, 2024
2 parents 928c62b + f8fcc6b commit 6985d18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ObservabilityBuilder } from '@aws-quickstart/eks-blueprints';
import * as cdk from "aws-cdk-lib";
import * as eks from 'aws-cdk-lib/aws-eks';
import * as iam from 'aws-cdk-lib/aws-iam';
import { AmpClient, TagResourceCommand } from "@aws-sdk/client-amp";

export default class ExistingEksOpenSourceobservabilityPattern {
async buildAsync(scope: cdk.App, _id: string) {
Expand Down Expand Up @@ -81,12 +82,14 @@ export default class ExistingEksOpenSourceobservabilityPattern {
.resourceProvider(blueprints.GlobalResources.Vpc, new blueprints.VpcProvider(vpcId)) // this is required with import cluster provider
.build(scope, stackId);

new iam.OpenIdConnectProvider(obs.getClusterInfo().cluster.stack, 'OIDCProvider', {
const stack = obs.getClusterInfo().cluster.stack;

new iam.OpenIdConnectProvider(stack, 'OIDCProvider', {
url: sdkCluster.identity!.oidc!.issuer!,
clientIds: ['sts.amazonaws.com'],
});

const clusterRole = new iam.Role(obs.getClusterInfo().cluster.stack, 'ClusterAdminRole', {
const clusterRole = new iam.Role(stack, 'ClusterAdminRole', {
assumedBy: new iam.CompositePrincipal(
new iam.ServicePrincipal("eks.amazonaws.com"),
new iam.AccountPrincipal(account).withConditions(
Expand All @@ -97,7 +100,7 @@ export default class ExistingEksOpenSourceobservabilityPattern {
description: 'Deployed by AWS Managed OSS EKS Infrastructure Observability Solution'
});

new eks.CfnAccessEntry(obs.getClusterInfo().cluster.stack, 'MyCfnAccessEntry', {
new eks.CfnAccessEntry(stack, 'MyCfnAccessEntry', {
clusterName: clusterName,
principalArn: clusterRole.roleArn,
accessPolicies: [{
Expand Down Expand Up @@ -134,8 +137,20 @@ export default class ExistingEksOpenSourceobservabilityPattern {

scraper.node.addDependency(obs)

cdk.Tags.of(obs.getClusterInfo().cluster.stack)
.add('o11y', "eks-infra-v" + utils.valueFromContext(scope, "solutionVersion", "2.0.0"));
const versionNumber = utils.valueFromContext(scope, "solutionVersion", "2.0.0")

cdk.Tags.of(stack)
.add('o11y-eks-infra', "v-" + versionNumber);

// Tag existing AMP workspace with version number
const ampClient = new AmpClient();
const tagInput = {
resourceArn: ampWorkspaceArn,
tags: {
"o11y-eks-infra":"v-" + versionNumber,
},
};
await ampClient.send(new TagResourceCommand(tagInput));
}
}

Expand Down
1 change: 1 addition & 0 deletions solutions/oss/eks-infra/v2.0.0/iac/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"aws-cdk": "2.133.0",
"aws-cdk-lib": "^2.135.0",
"aws-sdk": "^2.1455.0",
"@aws-sdk/client-amp": "^3.596.0",
"constructs": "^10.3.0",
"eks-blueprints-cdk-kubeflow-ext": "0.1.9",
"source-map-support": "^0.5.21"
Expand Down

0 comments on commit 6985d18

Please sign in to comment.