Skip to content

Commit

Permalink
Remove workarounds for codegen bugs (#536)
Browse files Browse the repository at this point in the history
Now that we've fixed the underlying issues, we can remove the workarounds and expose a few more properties.
  • Loading branch information
justinvp authored Feb 13, 2021
1 parent fb49464 commit b5deb21
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 169 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- Documentation addend for build dependencies
[#527](https://github.com/pulumi/pulumi-eks/issues/527)

- Expose some more properties to Python, .NET, and Go
[#536](https://github.com/pulumi/pulumi-eks/pull/536)

## 0.22.0 (Released January 27, 2021)

### Improvements
Expand Down
3 changes: 3 additions & 0 deletions dotnet/Inputs/CoreDataArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public sealed class CoreDataArgs : Pulumi.ResourceArgs
[Input("eksNodeAccess")]
public Input<Pulumi.Kubernetes.Core.V1.ConfigMap>? EksNodeAccess { get; set; }

[Input("encryptionConfig")]
public Input<Pulumi.Aws.Eks.Inputs.ClusterEncryptionConfigArgs>? EncryptionConfig { get; set; }

[Input("endpoint", required: true)]
public Input<string> Endpoint { get; set; } = null!;

Expand Down
23 changes: 23 additions & 0 deletions dotnet/ManagedNodeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public InputMap<string> Labels
set => _labels = value;
}

/// <summary>
/// Launch Template settings.
/// </summary>
[Input("launchTemplate")]
public Input<Pulumi.Aws.Eks.Inputs.NodeGroupLaunchTemplateArgs>? LaunchTemplate { get; set; }

/// <summary>
/// Name of the EKS Node Group.
/// </summary>
Expand Down Expand Up @@ -134,6 +140,23 @@ public InputMap<string> Labels
[Input("releaseVersion")]
public Input<string>? ReleaseVersion { get; set; }

/// <summary>
/// Remote access settings.
/// </summary>
[Input("remoteAccess")]
public Input<Pulumi.Aws.Eks.Inputs.NodeGroupRemoteAccessArgs>? RemoteAccess { get; set; }

/// <summary>
/// Scaling settings.
///
/// Default scaling amounts of the node group autoscaling group are:
/// - desiredSize: 2
/// - minSize: 1
/// - maxSize: 2
/// </summary>
[Input("scalingConfig")]
public Input<Pulumi.Aws.Eks.Inputs.NodeGroupScalingConfigArgs>? ScalingConfig { get; set; }

[Input("subnetIds")]
private InputList<string>? _subnetIds;

Expand Down
4 changes: 4 additions & 0 deletions dotnet/Outputs/CoreData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class CoreData
public readonly Pulumi.Aws.Eks.Cluster Cluster;
public readonly Pulumi.Aws.Ec2.SecurityGroup ClusterSecurityGroup;
public readonly Pulumi.Kubernetes.Core.V1.ConfigMap? EksNodeAccess;
public readonly Pulumi.Aws.Eks.Outputs.ClusterEncryptionConfig? EncryptionConfig;
public readonly string Endpoint;
public readonly Pulumi.Aws.Eks.FargateProfile? FargateProfile;
public readonly ImmutableArray<Pulumi.Aws.Iam.Role> InstanceRoles;
Expand All @@ -43,6 +44,8 @@ private CoreData(

Pulumi.Kubernetes.Core.V1.ConfigMap? eksNodeAccess,

Pulumi.Aws.Eks.Outputs.ClusterEncryptionConfig? encryptionConfig,

string endpoint,

Pulumi.Aws.Eks.FargateProfile? fargateProfile,
Expand Down Expand Up @@ -77,6 +80,7 @@ private CoreData(
Cluster = cluster;
ClusterSecurityGroup = clusterSecurityGroup;
EksNodeAccess = eksNodeAccess;
EncryptionConfig = encryptionConfig;
Endpoint = endpoint;
FargateProfile = fargateProfile;
InstanceRoles = instanceRoles;
Expand Down
11 changes: 5 additions & 6 deletions examples/managed-nodegroups-py/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@
cluster=cluster.core, # TODO[pulumi/pulumi-eks#483]: Pass cluster directly.
node_group_name="aws-managed-ng2",
node_role_arn=role2.arn,
# TODO[pulumi/pulumi#5819]: Add this back when it's available in the schema.
# scaling_config=eks.ManagedNodeGroupScalingConfigArgs(
# desired_size=1,
# min_size=1,
# max_size=2,
# ),
scaling_config=aws.eks.NodeGroupScalingConfigArgs(
desired_size=1,
min_size=1,
max_size=2,
),
disk_size=20,
instance_types=["t2.medium"],
labels={"ondemand": "true"},
Expand Down
157 changes: 19 additions & 138 deletions provider/cmd/pulumi-gen-eks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/pkg/errors"
dotnetgen "github.com/pulumi/pulumi/pkg/v2/codegen/dotnet"
Expand Down Expand Up @@ -613,14 +612,10 @@ func generateSchema() schema.PackageSpec {
"API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group " +
"will not be managed.",
},
// TODO[pulumi/pulumi/#5819]: The `launchTemplate` property causes a panic in the Python codegen:
// panic: interface conversion: interface {} is json.RawMessage, not python.PropertyInfo
// github.com/pulumi/pulumi/pkg/v2/codegen/python.recordProperty(0xc000d8c8c0, 0xc0016fc2a0, 0xc0016fc2d0, 0xc000548f58)
// github.com/pulumi/pulumi/pkg/v2@v2.14.1-0.20201121160205-9a707c4e03b6/codegen/python/gen.go:1446 +0x3d4
// "launchTemplate": {
// TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupLaunchTemplate:NodeGroupLaunchTemplate")},
// Description: "Launch Template settings.",
// },
"launchTemplate": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupLaunchTemplate:NodeGroupLaunchTemplate")},
Description: "Launch Template settings.",
},
"nodeGroupName": {
TypeSpec: schema.TypeSpec{Type: "string"},
Description: "Name of the EKS Node Group.",
Expand All @@ -642,22 +637,18 @@ func generateSchema() schema.PackageSpec {
TypeSpec: schema.TypeSpec{Type: "string"},
Description: "AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version.",
},
// TODO[pulumi/pulumi/#5819]: The `remoteAccess` and `scalingConfig` properties causes a panic in the Python codegen:
// panic: interface conversion: interface {} is json.RawMessage, not python.PropertyInfo
// github.com/pulumi/pulumi/pkg/v2/codegen/python.recordProperty(0xc000d8c8c0, 0xc0016fc2a0, 0xc0016fc2d0, 0xc000548f58)
// github.com/pulumi/pulumi/pkg/v2@v2.14.1-0.20201121160205-9a707c4e03b6/codegen/python/gen.go:1446 +0x3d4
// "remoteAccess": {
// TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupRemoteAccess:NodeGroupRemoteAccess")},
// Description: "Remote access settings.",
// },
// "scalingConfig": {
// TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupScalingConfig:NodeGroupScalingConfig")},
// Description: "Scaling settings.\n\n" +
// "Default scaling amounts of the node group autoscaling group are:\n" +
// " - desiredSize: 2\n" +
// " - minSize: 1\n" +
// " - maxSize: 2",
// },
"remoteAccess": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupRemoteAccess:NodeGroupRemoteAccess")},
Description: "Remote access settings.",
},
"scalingConfig": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FNodeGroupScalingConfig:NodeGroupScalingConfig")},
Description: "Scaling settings.\n\n" +
"Default scaling amounts of the node group autoscaling group are:\n" +
" - desiredSize: 2\n" +
" - minSize: 1\n" +
" - maxSize: 2",
},
"subnetIds": {
TypeSpec: schema.TypeSpec{
Type: "array",
Expand Down Expand Up @@ -870,13 +861,9 @@ func generateSchema() schema.PackageSpec {
"oidcProvider": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/resources/aws:iam%2FopenIdConnectProvider:OpenIdConnectProvider")},
},
// TODO[pulumi/pulumi/#5819]: The `encryptionConfig` property causes a panic in the Python codegen:
// panic: interface conversion: interface {} is json.RawMessage, not python.PropertyInfo
// github.com/pulumi/pulumi/pkg/v2/codegen/python.recordProperty(0xc000d8c8c0, 0xc0016fc2a0, 0xc0016fc2d0, 0xc000548f58)
// github.com/pulumi/pulumi/pkg/v2@v2.14.1-0.20201121160205-9a707c4e03b6/codegen/python/gen.go:1446 +0x3d4
// "encryptionConfig": {
// TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FClusterEncryptionConfig:ClusterEncryptionConfig")},
// },
"encryptionConfig": {
TypeSpec: schema.TypeSpec{Ref: awsRef("#/types/aws:eks%2FClusterEncryptionConfig:ClusterEncryptionConfig")},
},
},
Required: []string{
"cluster",
Expand Down Expand Up @@ -1515,47 +1502,6 @@ func genDotNet(pkg *schema.Package, outdir string) {
if err != nil {
panic(err)
}

// These are mistakenly added by the codegenerator.
delete(files, "Core/README.md")
delete(files, "Core/v1/README.md")
delete(files, "Eks/README.md")
delete(files, "Meta/README.md")
delete(files, "Meta/v1/README.md")

// There are some bugs in the codegen. Temporarily workaround them.
// https://github.com/pulumi/pulumi/pull/5810
// https://github.com/pulumi/pulumi/pull/5811
replacer := strings.NewReplacer(
"Pulumi.Pulumi.Aws", "Pulumi.Aws.Provider",
"Pulumi.Pulumi.Kubernetes", "Pulumi.Kubernetes.Provider",
"using Cluster;\n", "",
"using ConfigMap;\n", "",
"using FargateProfile;\n", "",
"using InstanceProfile;\n", "",
"using NodeGroup;\n", "",
"using OpenIdConnectProvider;\n", "",
"using Role;\n", "",
"using SecurityGroup;\n", "",
"using SecurityGroupRule;\n", "",
"using Stack;\n", "",
"using StorageClass;\n", "",
"Pulumi.Aws.Cloudformation/stack.Stack", "Pulumi.Aws.CloudFormation.Stack",
"Pulumi.Aws.Ec2/securityGroup.SecurityGroup", "Pulumi.Aws.Ec2.SecurityGroup",
"Pulumi.Aws.Ec2/securityGroupRule.SecurityGroupRule", "Pulumi.Aws.Ec2.SecurityGroupRule",
"Pulumi.Aws.Eks/cluster.Cluster", "Pulumi.Aws.Eks.Cluster",
"Pulumi.Aws.Eks/fargateProfile.FargateProfile", "Pulumi.Aws.Eks.FargateProfile",
"Pulumi.Aws.Eks/nodeGroup.NodeGroup", "Pulumi.Aws.Eks.NodeGroup",
"Pulumi.Aws.Iam/instanceProfile.InstanceProfile", "Pulumi.Aws.Iam.InstanceProfile",
"Pulumi.Aws.Iam/openIdConnectProvider.OpenIdConnectProvider", "Pulumi.Aws.Iam.OpenIdConnectProvider",
"Pulumi.Aws.Iam/role.Role", "Pulumi.Aws.Iam.Role",
"Pulumi.Kubernetes.Core/v1.ConfigMap", "Pulumi.Kubernetes.Core.V1.ConfigMap",
"Pulumi.Kubernetes.Storage.k8s.io/v1.StorageClass", "Pulumi.Kubernetes.Storage.V1.StorageClass")
for file, b := range files {
replaced := replacer.Replace(string(b))
files[file] = []byte(replaced)
}

mustWriteFiles(outdir, files)
}

Expand All @@ -1572,71 +1518,6 @@ func genPython(pkg *schema.Package, outdir string) {
if err != nil {
panic(err)
}

// The generated import for the `VpcCni` resource results in the following error:
//
// File "/Users/user/go/src/github.com/pulumi/pulumi-eks/python/bin/pulumi_eks/__init__.py", line 6, in <module>
// from .cluster import *
// File "/Users/user/go/src/github.com/pulumi/pulumi-eks/python/bin/pulumi_eks/cluster.py", line 10, in <module>
// from . import VpcCni
// ImportError: cannot import name 'VpcCni' from partially initialized module 'pulumi_eks' (most likely due to a
// circular import) (/Users/user/go/src/github.com/pulumi/pulumi-eks/python/bin/pulumi_eks/__init__.py)
//
// Until we've fixed this codegen bug, we'll workaround here by replacing how `VpcCni` is imported.
for file, b := range files {
replaced := strings.ReplaceAll(string(b), "from . import VpcCni", "from .vpc_cni import VpcCni")
files[file] = []byte(replaced)
}

// There are some bugs in the codegen. Temporarily workaround them.
// https://github.com/pulumi/pulumi/pull/5810
// https://github.com/pulumi/pulumi/pull/5811
replacer := strings.NewReplacer(
"\n# Make subpackages available:\nfrom . import (\n)\n", "",
"from pulumi_pulumi import Aws", "import pulumi_aws",
"from pulumi_pulumi import Kubernetes", "import pulumi_kubernetes",
"from pulumi_aws import _cloudformation_stack.Stack", "import pulumi_aws",
"from pulumi_aws import _ec2_securitygroup.SecurityGroup", "import pulumi_aws",
"from pulumi_aws import _ec2_securitygrouprule.SecurityGroupRule", "import pulumi_aws",
"from pulumi_aws import _eks_cluster.Cluster", "import pulumi_aws",
"from pulumi_aws import _eks_fargateprofile.FargateProfile", "import pulumi_aws",
"from pulumi_aws import _eks_nodegroup.NodeGroup", "import pulumi_aws",
"from pulumi_aws import _iam_instanceprofile.InstanceProfile", "import pulumi_aws",
"from pulumi_aws import _iam_openidconnectprovider.OpenIdConnectProvider", "import pulumi_aws",
"from pulumi_aws import _iam_role.Role", "import pulumi_aws",
"from pulumi_aws import eks_fargateprofileselector as _eks_fargateprofileselector", "import pulumi_aws",
"from pulumi_kubernetes import core_v1 as _core_v1", "import pulumi_kubernetes",
"from pulumi_kubernetes import meta_v1 as _meta_v1", "import pulumi_kubernetes",
"from pulumi_kubernetes import _storage_k8s_io_v1.StorageClass", "import pulumi_kubernetes",
"from pulumi_kubernetes import _core_v1.ConfigMap", "import pulumi_kubernetes",
"'Aws'", "'pulumi_aws.Provider'",
"'Kubernetes'", "'pulumi_kubernetes.Provider'",
"_cloudformation_stack.Stack", "pulumi_aws.cloudformation.Stack",
"_core_v1.ConfigMap", "pulumi_kubernetes.core.v1.ConfigMap",
"_ec2_securitygroup.SecurityGroup", "pulumi_aws.ec2.SecurityGroup",
"_ec2_securitygrouprule.SecurityGroupRule", "pulumi_aws.ec2.SecurityGroupRule",
"_eks_cluster.Cluster", "pulumi_aws.eks.Cluster",
"_eks_fargateprofile.FargateProfile", "pulumi_aws.eks.FargateProfile",
"_eks_fargateprofileselector.FargateProfileSelectorArgs", "pulumi_aws.eks.FargateProfileSelectorArgs",
"_eks_nodegroup.NodeGroup", "pulumi_aws.eks.NodeGroup",
"_iam_instanceprofile.InstanceProfile", "pulumi_aws.iam.InstanceProfile",
"_iam_openidconnectprovider.OpenIdConnectProvider", "pulumi_aws.iam.OpenIdConnectProvider",
"_iam_role.Role", "pulumi_aws.iam.Role",
"_meta_v1.ObjectMetaArgs", "pulumi_kubernetes.meta.v1.ObjectMetaArgs",
"_storage_k8s_io_v1.StorageClass", "pulumi_kubernetes.storage.v1.StorageClass")
importReplacer := strings.NewReplacer(
"import pulumi_aws\nimport pulumi_aws", "import pulumi_aws",
"import pulumi_kubernetes\nimport pulumi_kubernetes", "import pulumi_kubernetes",
"import pulumi_kubernetes\nimport pulumi_aws\n", "")
for file, b := range files {
replaced := replacer.Replace(string(b))
// Run this an arbitrary number of times to avoid duplicate imports.
for i := 0; i < 25; i++ {
replaced = importReplacer.Replace(replaced)
}
files[file] = []byte(replaced)
}

mustWriteFiles(outdir, files)
}

Expand Down
15 changes: 15 additions & 0 deletions provider/cmd/pulumi-resource-eks/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
"eksNodeAccess": {
"$ref": "/kubernetes/v2.7.7/schema.json#/resources/kubernetes:core%2Fv1:ConfigMap"
},
"encryptionConfig": {
"$ref": "/aws/v3.25.1/schema.json#/types/aws:eks%2FClusterEncryptionConfig:ClusterEncryptionConfig"
},
"endpoint": {
"type": "string"
},
Expand Down Expand Up @@ -869,6 +872,10 @@
},
"description": "Key-value map of Kubernetes labels. Only labels that are applied with the EKS API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group will not be managed."
},
"launchTemplate": {
"$ref": "/aws/v3.25.1/schema.json#/types/aws:eks%2FNodeGroupLaunchTemplate:NodeGroupLaunchTemplate",
"description": "Launch Template settings."
},
"nodeGroupName": {
"type": "string",
"description": "Name of the EKS Node Group."
Expand All @@ -885,6 +892,14 @@
"type": "string",
"description": "AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version."
},
"remoteAccess": {
"$ref": "/aws/v3.25.1/schema.json#/types/aws:eks%2FNodeGroupRemoteAccess:NodeGroupRemoteAccess",
"description": "Remote access settings."
},
"scalingConfig": {
"$ref": "/aws/v3.25.1/schema.json#/types/aws:eks%2FNodeGroupScalingConfig:NodeGroupScalingConfig",
"description": "Scaling settings.\n\nDefault scaling amounts of the node group autoscaling group are:\n - desiredSize: 2\n - minSize: 1\n - maxSize: 2"
},
"subnetIds": {
"type": "array",
"items": {
Expand Down
4 changes: 2 additions & 2 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v2 v2.19.1-0.20210130005200-e86a69beddea
github.com/pulumi/pulumi/sdk/v2 v2.19.1-0.20210130005200-e86a69beddea
github.com/pulumi/pulumi/pkg/v2 v2.20.1-0.20210212235419-bdc309bb4a7a
github.com/pulumi/pulumi/sdk/v2 v2.20.1-0.20210212235419-bdc309bb4a7a
github.com/spf13/pflag v1.0.5 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
4 changes: 4 additions & 0 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,15 @@ github.com/pulumi/pulumi/pkg/v2 v2.18.2 h1:9Y+adTednOM8Xm97oFqLNNlrQGmhT0rR8p5y3
github.com/pulumi/pulumi/pkg/v2 v2.18.2/go.mod h1:bAbzFeU3gHu1diqcckqUqaFf5dP02BfJlP8dnHwm00k=
github.com/pulumi/pulumi/pkg/v2 v2.19.1-0.20210130005200-e86a69beddea h1:cyfYoiZcwk4Na74aYrrvGzPoerxUQyRSLTMSzSNUN1I=
github.com/pulumi/pulumi/pkg/v2 v2.19.1-0.20210130005200-e86a69beddea/go.mod h1:bAbzFeU3gHu1diqcckqUqaFf5dP02BfJlP8dnHwm00k=
github.com/pulumi/pulumi/pkg/v2 v2.20.1-0.20210212235419-bdc309bb4a7a h1:wfIDCW4I3FRbSGdUY72H9iB+LYziUA7E40wOD8GOenU=
github.com/pulumi/pulumi/pkg/v2 v2.20.1-0.20210212235419-bdc309bb4a7a/go.mod h1:bAbzFeU3gHu1diqcckqUqaFf5dP02BfJlP8dnHwm00k=
github.com/pulumi/pulumi/sdk/v2 v2.2.1/go.mod h1:QNbWpL4gvf3X0lUFT7TXA2Jo1ff/Ti2l97AyFGYwvW4=
github.com/pulumi/pulumi/sdk/v2 v2.18.2 h1:LMgbPunosWURPPcLPZXk/JQiq2UiMbNaC+R1OtZU+aY=
github.com/pulumi/pulumi/sdk/v2 v2.18.2/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqLlS54JJIwfOt+o=
github.com/pulumi/pulumi/sdk/v2 v2.19.1-0.20210130005200-e86a69beddea h1:PDWoIX/jl0GAHqxB/4TJPUCyVaL0W49yzGXYzy6lR6g=
github.com/pulumi/pulumi/sdk/v2 v2.19.1-0.20210130005200-e86a69beddea/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqLlS54JJIwfOt+o=
github.com/pulumi/pulumi/sdk/v2 v2.20.1-0.20210212235419-bdc309bb4a7a h1:TulVnC2Dax4wCYaLHo9W+6PzOLrhqz2XF1wETaFm3FI=
github.com/pulumi/pulumi/sdk/v2 v2.20.1-0.20210212235419-bdc309bb4a7a/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqLlS54JJIwfOt+o=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
Expand Down
Loading

0 comments on commit b5deb21

Please sign in to comment.