aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.66k stars 3.92k forks source link

[aws-eks] cdk8s charts example error #10785

Closed neilkuan closed 4 years ago

neilkuan commented 4 years ago

Example error https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/aws-eks#cdk8s-charts

have error in my-charts.ts example

import * as s3 from '@aws-cdk/aws-s3';
import * as constructs from 'constructs';
import * as cdk8s from 'cdk8s';
import * as kplus from 'cdk8s-plus';

export interface MyChartProps {
  readonly bucket: s3.Bucket;
}

export class MyChart extends cdk8s.Chart {
  constructor(scope: constructs.Construct, id: string, props: MyChartProps} ) {
    super(scope, id);

    new kplus.Pod(this, 'Pod', {
      spec: {
        containers: [
          new kplus.Container({
            image: 'my-image',
            env: {
              BUCKET_NAME: bucket.bucketName,
            }
          })
        ]
      }
    });
  }
}

correct example

import * as s3 from '@aws-cdk/aws-s3';
import * as cdk8s from 'cdk8s';
import * as kplus from 'cdk8s-plus';
import * as constructs from 'constructs';

export interface MyChartProps {
  readonly bucket: s3.Bucket;
}

export class MyChart extends cdk8s.Chart {
  constructor(scope: constructs.Construct, id: string, props: MyChartProps) {
    super(scope, id);

    new kplus.Pod(this, 'Pod', {
      spec: {
        containers: [
          new kplus.Container({
            image: 'my-image',
            env: {
              BUCKET_NAME: kplus.EnvValue.fromValue(props.bucket.bucketName),
            },
          }),
        ],
      },
    });
  }
}

This is a 📕 documentation issue

github-actions[bot] commented 4 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.