jsii icon indicating copy to clipboard operation
jsii copied to clipboard

(Amazon.CDK.AWS.EKS.CfnCluster): Documentation sample does not work as shown

Open cchostak opened this issue 2 years ago • 2 comments

link to reference doc page

https://docs.aws.amazon.com/cdk/api/v1/dotnet/api/Amazon.CDK.AWS.EKS.CfnCluster.html

Describe your issue?

.csproj


  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp5</TargetFramework>
    <!-- Roll forward to future major versions of the netcoreapp as needed -->
    <RollForward>Major</RollForward>
  </PropertyGroup>

  <ItemGroup>
    <!-- CDK Construct Library dependencies -->
    <PackageReference Include="Amazon.CDK.Lib" Version="2.17.0" />
    <PackageReference Include="Constructs" Version="[10.0.0,11.0.0)" />

    <!-- jsii Roslyn analyzers (un-comment to obtain compile-time checks for missing required props
    <PackageReference Include="Amazon.Jsii.Analyzers" Version="*" PrivateAssets="all" />
    -->
  </ItemGroup>

</Project>

EksCdkStack.cs

... boilerplate
            CfnCluster cfnCluster = new CfnCluster(this, Constants.CLUSTER_PREFIX, new CfnClusterProps
            {
                ResourcesVpcConfig = new ResourcesVpcConfigProperty
                {
                    SubnetIds = new[] { combinedSubnets },
                    EndpointPrivateAccess = isClusterPublic ? false : true,
                    EndpointPublicAccess = isClusterPublic ? true : false,
                },
                RoleArn = clusterAdmin.RoleArn,
                Name = clusterName.ValueAsString,
                Version = clusterVersion.ValueAsString
            });
... boilerplate

Documentation clearly states that we can use 'ResourcesVpcConfig = new ResourcesVpcConfigProperty', but:

  • not using ResourcesVpcConfigProperty, I receive the error (cool, as expected):
Unhandled exception. Amazon.JSII.Runtime.JsiiException: Missing required properties for aws-cdk-lib.aws_eks.CfnClusterProps: resourcesVpcConfig
  • using ResourcesVpcConfigProperty, it shows me:
The type or namespace name 'ResourcesVpcConfigProperty' could not be found (are you missing a using directive or an assembly reference?
  • using ResourcesVpcConfig, it shows me:
The type or namespace name 'ResourcesVpcConfig' could not be found (are you missing a using directive or an assembly reference?

cchostak avatar Mar 28 '22 08:03 cchostak

@MrArnoldPalmer potentially a Go issue

peterwoodworth avatar Mar 28 '22 18:03 peterwoodworth

This looks like an issue with automatically generated documentation for Dotnet not including namespacing where needed. Likely a bug with jsii-rosetta. @rix0rrr are you aware of any related bugs?

I believe this example should look like:

Show Code!
           CfnCluster cfnCluster = new CfnCluster(this, "MyCfnCluster", new CfnClusterProps {
              ResourcesVpcConfig = new CfnCluster.ResourcesVpcConfigProperty {
                  SubnetIds = new [] { "subnetIds" },

                  // the properties below are optional
                  EndpointPrivateAccess = false,
                  EndpointPublicAccess = false,
                  PublicAccessCidrs = new [] { "publicAccessCidrs" },
                  SecurityGroupIds = new [] { "securityGroupIds" }
              },
              RoleArn = "roleArn",

              // the properties below are optional
              EncryptionConfig = new [] { new CfnCluster.EncryptionConfigProperty {
                  Provider = provider,
                  Resources = new [] { "resources" }
              } },
              KubernetesNetworkConfig = new CfnCluster.KubernetesNetworkConfigProperty {
                  IpFamily = "ipFamily",
                  ServiceIpv4Cidr = "serviceIpv4Cidr",
                  ServiceIpv6Cidr = "serviceIpv6Cidr"
              },
              Logging = new CfnCluster.LoggingProperty {
                  ClusterLogging = new CfnCluster.ClusterLoggingProperty {
                      EnabledTypes = new [] { new CfnCluster.LoggingTypeConfigProperty {
                          Type = "type"
                      } }
                  }
              },
              Name = "name",
              Tags = new [] { new CfnTag {
                  Key = "key",
                  Value = "value"
              } },
              Version = "version"
          });           // The code that defines your stack goes here

@peterwoodworth this is unrelated to Go

MrArnoldPalmer avatar Mar 28 '22 20:03 MrArnoldPalmer