pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
197 stars 43 forks source link

Conversion error: `could not generate output program: invalid Go source code` #1158

Closed justinvp closed 1 year ago

justinvp commented 1 year ago

Error converting https://github.com/terraform-aws-modules/terraform-aws-alb to Go:

pulumi convert --from terraform --language go --out pulumigo
warning: Plugin converters are currently experimental
error: could not generate output program: invalid Go source code:

package main

import (
"fmt"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lambda"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/lb"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func notImplemented(message string) pulumi.AnyOutput {
    panic(message)
}

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
// Controls if the Load Balancer should be created
createLb := true;
if param := cfg.GetBool("createLb"); param {
createLb = param
}
// Indicates whether invalid header fields are dropped in application load balancers. Defaults to false.
dropInvalidHeaderFields := false;
if param := cfg.GetBool("dropInvalidHeaderFields"); param {
dropInvalidHeaderFields = param
}
// Indicates whether Host header should be preserve and forward to targets without any change. Defaults to false.
preserveHostHeader := false;
if param := cfg.GetBool("preserveHostHeader"); param {
preserveHostHeader = param
}
// If true, deletion of the load balancer will be disabled via the AWS API. This will prevent Terraform from deleting the load balancer. Defaults to false.
enableDeletionProtection := false;
if param := cfg.GetBool("enableDeletionProtection"); param {
enableDeletionProtection = param
}
// Indicates whether HTTP/2 is enabled in application load balancers.
enableHttp2 := true;
if param := cfg.GetBool("enableHttp2"); param {
enableHttp2 = param
}
// Indicates whether cross zone load balancing should be enabled in application load balancers.
enableCrossZoneLoadBalancing := false;
if param := cfg.GetBool("enableCrossZoneLoadBalancing"); param {
enableCrossZoneLoadBalancing = param
}
// Indicates whether the two headers (x-amzn-tls-version and x-amzn-tls-cipher-suite), which contain information about the negotiated TLS version and cipher suite, are added to the client request before sending it to the target.
enableTlsVersionAndCipherSuiteHeaders := false;
if param := cfg.GetBool("enableTlsVersionAndCipherSuiteHeaders"); param {
enableTlsVersionAndCipherSuiteHeaders = param
}
// Indicates whether the X-Forwarded-For header should preserve the source port that the client used to connect to the load balancer in application load balancers.
enableXffClientPort := true;
if param := cfg.GetBool("enableXffClientPort"); param {
enableXffClientPort = param
}
// A list of maps describing any extra SSL certificates to apply to the HTTPS listeners. Required key/values: certificate_arn, https_listener_index (the index of the listener within https_listeners which the cert applies toward).
extraSslCerts := []interface{}{
};
if param := cfg.GetBool("extraSslCerts"); param != nil {
extraSslCerts = param
}
// A list of maps describing the HTTPS listeners for this ALB. Required key/values: port, certificate_arn. Optional key/values: ssl_policy (defaults to ELBSecurityPolicy-2016-08), target_group_index (defaults to https_listeners[count.index])
httpsListeners := []interface{}{
};
if param := cfg.GetBool("httpsListeners"); param != nil {
httpsListeners = param
}
// A list of maps describing the HTTP listeners or TCP ports for this ALB. Required key/values: port, protocol. Optional key/values: target_group_index (defaults to http_tcp_listeners[count.index])
httpTcpListeners := []interface{}{
};
if param := cfg.GetBool("httpTcpListeners"); param != nil {
httpTcpListeners = param
}
// A list of maps describing the Listener Rules for this ALB. Required key/values: actions, conditions. Optional key/values: priority, https_listener_index (default to https_listeners[count.index])
httpsListenerRules := []interface{}{
};
if param := cfg.GetBool("httpsListenerRules"); param != nil {
httpsListenerRules = param
}
// A list of maps describing the Listener Rules for this ALB. Required key/values: actions, conditions. Optional key/values: priority, http_tcp_listener_index (default to http_tcp_listeners[count.index])
httpTcpListenerRules := []interface{}{
};
if param := cfg.GetBool("httpTcpListenerRules"); param != nil {
httpTcpListenerRules = param
}
// The time in seconds that the connection is allowed to be idle.
idleTimeout := float64(60);
if param := cfg.GetFloat64("idleTimeout"); param != 0 {
idleTimeout = param
}
// The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack.
ipAddressType := "ipv4";
if param := cfg.Get("ipAddressType"); param != ""{
ipAddressType = param
}
// The security policy if using HTTPS externally on the load balancer. [See](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-policy-table.html).
listenerSslPolicyDefault := "ELBSecurityPolicy-2016-08";
if param := cfg.Get("listenerSslPolicyDefault"); param != ""{
listenerSslPolicyDefault = param
}
// Boolean determining if the load balancer is internal or externally facing.
internal := false;
if param := cfg.GetBool("internal"); param {
internal = param
}
// Timeout value when creating the ALB.
loadBalancerCreateTimeout := "10m";
if param := cfg.Get("loadBalancerCreateTimeout"); param != ""{
loadBalancerCreateTimeout = param
}
// Timeout value when deleting the ALB.
loadBalancerDeleteTimeout := "10m";
if param := cfg.Get("loadBalancerDeleteTimeout"); param != ""{
loadBalancerDeleteTimeout = param
}
// The resource name and Name tag of the load balancer.
name := nil;
if param := cfg.GetBool("name"); param != nil {
name = param
}
// The resource name prefix and Name tag of the load balancer. Cannot be longer than 6 characters
namePrefix := nil;
if param := cfg.GetBool("namePrefix"); param != nil {
namePrefix = param
}
// The type of load balancer to create. Possible values are application or network.
loadBalancerType := "application";
if param := cfg.Get("loadBalancerType"); param != ""{
loadBalancerType = param
}
// Timeout value when updating the ALB.
loadBalancerUpdateTimeout := "10m";
if param := cfg.Get("loadBalancerUpdateTimeout"); param != ""{
loadBalancerUpdateTimeout = param
}
// Map containing access logging configuration for load balancer.
accessLogs := nil;
if param := cfg.GetBool("accessLogs"); param != nil {
accessLogs = param
}
// A list of subnets to associate with the load balancer. e.g. ['subnet-1a2b3c4d','subnet-1a2b3c4e','subnet-1a2b3c4f']
subnets := nil;
if param := cfg.GetBool("subnets"); param != nil {
subnets = param
}
// A list of subnet mapping blocks describing subnets to attach to network load balancer
subnetMapping := []interface{}{
};
if param := cfg.GetBool("subnetMapping"); param != nil {
subnetMapping = param
}
// A map of tags to add to all resources
tags := nil;
if param := cfg.GetBool("tags"); param != nil {
tags = param
}
// A map of tags to add to load balancer
lbTags := nil;
if param := cfg.GetBool("lbTags"); param != nil {
lbTags = param
}
// A map of tags to add to all target groups
targetGroupTags := nil;
if param := cfg.GetBool("targetGroupTags"); param != nil {
targetGroupTags = param
}
// A map of tags to add to all https listener rules
httpsListenerRulesTags := nil;
if param := cfg.GetBool("httpsListenerRulesTags"); param != nil {
httpsListenerRulesTags = param
}
// A map of tags to add to all http listener rules
httpTcpListenerRulesTags := nil;
if param := cfg.GetBool("httpTcpListenerRulesTags"); param != nil {
httpTcpListenerRulesTags = param
}
// A map of tags to add to all https listeners
httpsListenersTags := nil;
if param := cfg.GetBool("httpsListenersTags"); param != nil {
httpsListenersTags = param
}
// A map of tags to add to all http listeners
httpTcpListenersTags := nil;
if param := cfg.GetBool("httpTcpListenersTags"); param != nil {
httpTcpListenersTags = param
}
// The security groups to attach to the load balancer. e.g. ["sg-edcd9784","sg-edcd9785"]
securityGroups := []interface{}{
};
if param := cfg.GetBool("securityGroups"); param != nil {
securityGroups = param
}
// A list of maps containing key/value pairs that define the target groups to be created. Order of these maps is important and the index of these are to be referenced in listener definitions. Required key/values: name, backend_protocol, backend_port
targetGroups := []interface{}{
};
if param := cfg.GetBool("targetGroups"); param != nil {
targetGroups = param
}
// VPC id where the load balancer and other resources will be deployed.
vpcId := nil;
if param := cfg.GetBool("vpcId"); param != nil {
vpcId = param
}
// Indicates whether to route requests to targets if lb fails to forward the request to AWS WAF
enableWafFailOpen := false;
if param := cfg.GetBool("enableWafFailOpen"); param {
enableWafFailOpen = param
}
// Determines how the load balancer handles requests that might pose a security risk to an application due to HTTP desync.
desyncMitigationMode := "defensive";
if param := cfg.Get("desyncMitigationMode"); param != ""{
desyncMitigationMode = param
}
// Determines how the load balancer modifies the X-Forwarded-For header in the HTTP request before sending the request to the target.
xffHeaderProcessingMode := "append";
if param := cfg.Get("xffHeaderProcessingMode"); param != ""{
xffHeaderProcessingMode = param
}
// Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!
putinKhuylo := true;
if param := cfg.GetBool("putinKhuylo"); param {
putinKhuylo = param
}
// Determines if a security group is created
createSecurityGroup := true;
if param := cfg.GetBool("createSecurityGroup"); param {
createSecurityGroup = param
}
// Name to use on security group created
securityGroupName := nil;
if param := cfg.GetBool("securityGroupName"); param != nil {
securityGroupName = param
}
// Determines whether the security group name (`security_group_name`) is used as a prefix
securityGroupUseNamePrefix := true;
if param := cfg.GetBool("securityGroupUseNamePrefix"); param {
securityGroupUseNamePrefix = param
}
// Description of the security group created
securityGroupDescription := nil;
if param := cfg.GetBool("securityGroupDescription"); param != nil {
securityGroupDescription = param
}
// Security group rules to add to the security group created
securityGroupRules := nil;
if param := cfg.GetBool("securityGroupRules"); param != nil {
securityGroupRules = param
}
// A map of additional tags to add to the security group created
securityGroupTags := nil;
if param := cfg.GetBool("securityGroupTags"); param != nil {
securityGroupTags = param
}
mycreateLb := createLb && putinKhuylo;
mycreateSecurityGroup := mycreateLb && createSecurityGroup && loadBalancerType == "application";
mysecurityGroupName := notImplemented("try(coalesce(var.security_group_name,var.name,var.name_prefix),\"\")");
var tmp0 pulumi.String
if securityGroupUseNamePrefix {
tmp0 = nil
} else {
tmp0 = pulumi.Any(mysecurityGroupName)
}
var tmp1 pulumi.String
if securityGroupUseNamePrefix {
tmp1 = pulumi.String(fmt.Sprintf("%v-", mysecurityGroupName))
} else {
tmp1 = nil
}
var tmp2 float64
if mycreateSecurityGroup {
tmp2 = 1
} else {
tmp2 = 0
}
var thisResource2 []*ec2.SecurityGroup
for index := 0; index < tmp2; index++ {
    key0 := index
    _ := index
__res, err := ec2.NewSecurityGroup(ctx, fmt.Sprintf("thisResource2-%v", key0), &ec2.SecurityGroupArgs{
Name: pulumi.String(tmp0),
NamePrefix: pulumi.String(tmp1),
Description: *pulumi.String(securityGroupDescription),
VpcId: *pulumi.String(vpcId),
Tags: notImplemented("merge(\nvar.tags,\nvar.security_group_tags,\n{\"Name\"=local.security_group_name},\n)"),
})
if err != nil {
return err
}
thisResource2 = append(thisResource2, __res)
}
var tmp3 pulumi.StringArray
if createSecurityGroup && loadBalancerType == "application" {
tmp3 = std.Concat(ctx, &std.ConcatArgs{
Input: []interface{}{
pulumi.StringArray{
thisResource2[0].ID(),
},
securityGroups,
},
}, nil).ApplyT(func(invoke std.ConcatResult) ([]interface{}, error) {
return invoke.Result, nil
}).(pulumi.[]interface{}Output)
} else {
tmp3 = securityGroups
}
var tmp4 float64
if mycreateLb {
tmp4 = 1
} else {
tmp4 = 0
}
var this []*lb.LoadBalancer
for index := 0; index < tmp4; index++ {
    key0 := index
    _ := index
__res, err := lb.NewLoadBalancer(ctx, fmt.Sprintf("this-%v", key0), &lb.LoadBalancerArgs{
SubnetMappings: "TODO: For expression",
AccessLogs: "TODO: For expression"[0],
Name: *pulumi.String(name),
NamePrefix: *pulumi.String(namePrefix),
LoadBalancerType: pulumi.String(loadBalancerType),
Internal: pulumi.Bool(internal),
SecurityGroups: tmp3,
Subnets: interface{}(subnets),
IdleTimeout: pulumi.Float64(idleTimeout),
EnableCrossZoneLoadBalancing: pulumi.Bool(enableCrossZoneLoadBalancing),
EnableDeletionProtection: pulumi.Bool(enableDeletionProtection),
EnableHttp2: pulumi.Bool(enableHttp2),
EnableTlsVersionAndCipherSuiteHeaders: pulumi.Bool(enableTlsVersionAndCipherSuiteHeaders),
EnableXffClientPort: pulumi.Bool(enableXffClientPort),
IpAddressType: pulumi.String(ipAddressType),
DropInvalidHeaderFields: pulumi.Bool(dropInvalidHeaderFields),
PreserveHostHeader: pulumi.Bool(preserveHostHeader),
EnableWafFailOpen: pulumi.Bool(enableWafFailOpen),
DesyncMitigationMode: pulumi.String(desyncMitigationMode),
XffHeaderProcessingMode: pulumi.String(xffHeaderProcessingMode),
Tags: notImplemented("merge(\n{\nName=(var.name!=null)?var.name:var.name_prefix\n},\nvar.tags,\nvar.lb_tags,\n)"),
})
if err != nil {
return err
}
this = append(this, __res)
}
var tmp5 float64
if mycreateLb {
tmp5 = len(targetGroups)
} else {
tmp5 = 0
}
var main []*lb.TargetGroup
for index := 0; index < tmp5; index++ {
    key0 := index
    _ := index
__res, err := lb.NewTargetGroup(ctx, fmt.Sprintf("main-%v", key0), &lb.TargetGroupArgs{
Stickiness: "TODO: For expression"[0],
HealthCheck: "TODO: For expression"[0],
Name: notImplemented("lookup(var.target_groups[count.index],\"name\",null)"),
NamePrefix: notImplemented("lookup(var.target_groups[count.index],\"name_prefix\",null)"),
VpcId: *pulumi.String(vpcId),
Port: notImplemented("try(var.target_groups[count.index].backend_port,null)"),
Protocol: notImplemented("try(upper(var.target_groups[count.index].backend_protocol),null)"),
ProtocolVersion: notImplemented("try(upper(var.target_groups[count.index].protocol_version),null)"),
TargetType: notImplemented("try(var.target_groups[count.index].target_type,null)"),
ConnectionTermination: notImplemented("try(var.target_groups[count.index].connection_termination,null)"),
DeregistrationDelay: notImplemented("try(var.target_groups[count.index].deregistration_delay,null)"),
SlowStart: notImplemented("try(var.target_groups[count.index].slow_start,null)"),
ProxyProtocolV2: notImplemented("try(var.target_groups[count.index].proxy_protocol_v2,false)"),
LambdaMultiValueHeadersEnabled: notImplemented("try(var.target_groups[count.index].lambda_multi_value_headers_enabled,false)"),
LoadBalancingAlgorithmType: notImplemented("try(var.target_groups[count.index].load_balancing_algorithm_type,null)"),
PreserveClientIp: notImplemented("try(var.target_groups[count.index].preserve_client_ip,null)"),
IpAddressType: notImplemented("try(var.target_groups[count.index].ip_address_type,null)"),
LoadBalancingCrossZoneEnabled: notImplemented("try(var.target_groups[count.index].load_balancing_cross_zone_enabled,null)"),
Tags: notImplemented("merge(\nvar.tags,\nvar.target_group_tags,\nlookup(var.target_groups[count.index],\"tags\",{}),\n{\n\"Name\"=try(var.target_groups[count.index].name,var.target_groups[count.index].name_prefix,\"\")\n},\n)"),
})
if err != nil {
return err
}
main = append(main, __res)
}
targetGroupAttachments := notImplemented("merge(flatten([\nforindex,groupinvar.target_groups:[\nfork,targetsingroup:{\nfortarget_key,targetintargets:join(\".\",[index,target_key])=>merge({tg_index=index},target)\n}\nifk==\"targets\"\n]\n])...)");
targetGroupAttachmentsLambda := "TODO: For expression";
var lb []*lambda.Permission
for key0, val0 := range "TODO: For expression" {
__res, err := lambda.NewPermission(ctx, fmt.Sprintf("lb-%v", key0), &lambda.PermissionArgs{
Function: pulumi.Any(val0),
Qualifier: notImplemented("try(each.value.lambda_qualifier,null)"),
StatementId: notImplemented("try(each.value.lambda_statement_id,\"AllowExecutionFromLb\")"),
Action: notImplemented("try(each.value.lambda_action,\"lambda:InvokeFunction\")"),
Principal: notImplemented("try(each.value.lambda_principal,\"elasticloadbalancing.amazonaws.com\")"),
SourceArn: main[val0].Arn,
SourceAccount: notImplemented("try(each.value.lambda_source_account,null)"),
EventSourceToken: notImplemented("try(each.value.lambda_event_source_token,null)"),
})
if err != nil {
return err
}
lb = append(lb, __res)
}
var thisResource []*lb.TargetGroupAttachment
for key0, val0 := range "TODO: For expression" {
__res, err := lb.NewTargetGroupAttachment(ctx, fmt.Sprintf("thisResource-%v", key0), &lb.TargetGroupAttachmentArgs{
TargetGroupArn: main[val0].Arn,
TargetId: pulumi.Any(val0),
Port: notImplemented("lookup(each.value,\"port\",null)"),
AvailabilityZone: notImplemented("lookup(each.value,\"availability_zone\",null)"),
})
if err != nil {
return err
}
thisResource = append(thisResource, __res)
}
var tmp6 float64
if mycreateLb {
tmp6 = len(httpsListeners)
} else {
tmp6 = 0
}
var frontendHttps []*lb.Listener
for index := 0; index < tmp6; index++ {
    key0 := index
    val0 := index
__res, err := lb.NewListener(ctx, fmt.Sprintf("frontendHttps-%v", key0), &lb.ListenerArgs{
DefaultActions: "TODO: For expression",
LoadBalancerArn: this[0].Arn,
Port: httpsListeners[val0].Port,
Protocol: notImplemented("lookup(var.https_listeners[count.index],\"protocol\",\"HTTPS\")"),
CertificateArn: httpsListeners[val0].Certificate_arn,
SslPolicy: notImplemented("lookup(var.https_listeners[count.index],\"ssl_policy\",var.listener_ssl_policy_default)"),
AlpnPolicy: notImplemented("lookup(var.https_listeners[count.index],\"alpn_policy\",null)"),
Tags: notImplemented("merge(\nvar.tags,\nvar.https_listeners_tags,\nlookup(var.https_listeners[count.index],\"tags\",{}),\n)"),
})
if err != nil {
return err
}
frontendHttps = append(frontendHttps, __res)
}
var tmp7 float64
if mycreateLb {
tmp7 = len(httpsListenerRules)
} else {
tmp7 = 0
}
var httpsListenerRule []*lb.ListenerRule
for index := 0; index < tmp7; index++ {
    key0 := index
    _ := index
__res, err := lb.NewListenerRule(ctx, fmt.Sprintf("httpsListenerRule-%v", key0), &lb.ListenerRuleArgs{
Conditions: "TODO: For expression",
Actions: "TODO: For expression",
ListenerArn: frontendHttps[notImplemented("lookup(var.https_listener_rules[count.index],\"https_listener_index\",count.index)")].Arn,
Priority: notImplemented("lookup(var.https_listener_rules[count.index],\"priority\",null)"),
Tags: notImplemented("merge(\nvar.tags,\nvar.https_listener_rules_tags,\nlookup(var.https_listener_rules[count.index],\"tags\",{}),\n)"),
})
if err != nil {
return err
}
httpsListenerRule = append(httpsListenerRule, __res)
}
var tmp8 float64
if mycreateLb {
tmp8 = len(httpTcpListeners)
} else {
tmp8 = 0
}
var frontendHttpTcp []*lb.Listener
for index := 0; index < tmp8; index++ {
    key0 := index
    val0 := index
__res, err := lb.NewListener(ctx, fmt.Sprintf("frontendHttpTcp-%v", key0), &lb.ListenerArgs{
DefaultActions: "TODO: For expression",
LoadBalancerArn: this[0].Arn,
Port: httpTcpListeners[val0].Port,
Protocol: httpTcpListeners[val0].Protocol,
Tags: notImplemented("merge(\nvar.tags,\nvar.http_tcp_listeners_tags,\nlookup(var.http_tcp_listeners[count.index],\"tags\",{}),\n)"),
})
if err != nil {
return err
}
frontendHttpTcp = append(frontendHttpTcp, __res)
}
var tmp9 float64
if mycreateLb {
tmp9 = len(httpTcpListenerRules)
} else {
tmp9 = 0
}
var httpTcpListenerRule []*lb.ListenerRule
for index := 0; index < tmp9; index++ {
    key0 := index
    _ := index
__res, err := lb.NewListenerRule(ctx, fmt.Sprintf("httpTcpListenerRule-%v", key0), &lb.ListenerRuleArgs{
Conditions: "TODO: For expression",
Actions: "TODO: For expression",
ListenerArn: frontendHttpTcp[notImplemented("lookup(var.http_tcp_listener_rules[count.index],\"http_tcp_listener_index\",count.index)")].Arn,
Priority: notImplemented("lookup(var.http_tcp_listener_rules[count.index],\"priority\",null)"),
Tags: notImplemented("merge(\nvar.tags,\nvar.http_tcp_listener_rules_tags,\nlookup(var.http_tcp_listener_rules[count.index],\"tags\",{}),\n)"),
})
if err != nil {
return err
}
httpTcpListenerRule = append(httpTcpListenerRule, __res)
}
var tmp10 float64
if mycreateLb {
tmp10 = len(extraSslCerts)
} else {
tmp10 = 0
}
var httpsListener []*lb.ListenerCertificate
for index := 0; index < tmp10; index++ {
    key0 := index
    val0 := index
__res, err := lb.NewListenerCertificate(ctx, fmt.Sprintf("httpsListener-%v", key0), &lb.ListenerCertificateArgs{
ListenerArn: frontendHttps[extraSslCerts[val0].Https_listener_index].Arn,
CertificateArn: extraSslCerts[val0].Certificate_arn,
})
if err != nil {
return err
}
httpsListener = append(httpsListener, __res)
}
var thisResource3 []*ec2.SecurityGroupRule
for key0, val0 := range "TODO: For expression" {
__res, err := ec2.NewSecurityGroupRule(ctx, fmt.Sprintf("thisResource3-%v", key0), &ec2.SecurityGroupRuleArgs{
SecurityGroupId: thisResource2[0].ID(),
Protocol: ec2.ProtocolType(val0),
FromPort: pulumi.Any(val0),
ToPort: pulumi.Any(val0),
Type: pulumi.Any(val0),
Description: notImplemented("lookup(each.value,\"description\",null)"),
CidrBlocks: notImplemented("lookup(each.value,\"cidr_blocks\",null)"),
Ipv6CidrBlocks: notImplemented("lookup(each.value,\"ipv6_cidr_blocks\",null)"),
PrefixListIds: notImplemented("lookup(each.value,\"prefix_list_ids\",null)"),
Self: notImplemented("lookup(each.value,\"self\",null)"),
SourceSecurityGroupId: notImplemented("lookup(each.value,\"source_security_group_id\",null)"),
})
if err != nil {
return err
}
thisResource3 = append(thisResource3, __res)
}
ctx.Export("lbId", notImplemented("try(aws_lb.this[0].id,\"\")"))
ctx.Export("lbArn", notImplemented("try(aws_lb.this[0].arn,\"\")"))
ctx.Export("lbDnsName", notImplemented("try(aws_lb.this[0].dns_name,\"\")"))
ctx.Export("lbArnSuffix", notImplemented("try(aws_lb.this[0].arn_suffix,\"\")"))
ctx.Export("lbZoneId", notImplemented("try(aws_lb.this[0].zone_id,\"\")"))
var splat0 pulumi.StringArray
for _, val0 := range frontendHttpTcp {
splat0 = append(splat0, val0.Arn)
}
ctx.Export("httpTcpListenerArns", splat0)
var splat1 pulumi.StringArray
for _, val0 := range frontendHttpTcp {
splat1 = append(splat1, val0.ID())
}
ctx.Export("httpTcpListenerIds", splat1)
var splat2 pulumi.StringArray
for _, val0 := range frontendHttps {
splat2 = append(splat2, val0.Arn)
}
ctx.Export("httpsListenerArns", splat2)
var splat3 pulumi.StringArray
for _, val0 := range frontendHttps {
splat3 = append(splat3, val0.ID())
}
ctx.Export("httpsListenerIds", splat3)
var splat4 pulumi.StringArray
for _, val0 := range main {
splat4 = append(splat4, val0.Arn)
}
ctx.Export("targetGroupArns", splat4)
var splat5 pulumi.StringArray
for _, val0 := range main {
splat5 = append(splat5, val0.ArnSuffix)
}
ctx.Export("targetGroupArnSuffixes", splat5)
var splat6 pulumi.StringArray
for _, val0 := range main {
splat6 = append(splat6, val0.Name)
}
ctx.Export("targetGroupNames", splat6)
ctx.Export("targetGroupAttachmentsOutput", "TODO: For expression")
ctx.Export("securityGroupArn", notImplemented("try(aws_security_group.this[0].arn,null)"))
ctx.Export("securityGroupId", notImplemented("try(aws_security_group.this[0].id,null)"))
return nil
})
}
: 307:12: expected 'IDENT', found '[' (and 2 more errors)
justinvp commented 1 year ago

Error converting https://github.com/terraform-aws-modules/terraform-aws-rds-aurora to Go:

pulumi convert --from terraform --language go --out pulumigo
warning: Plugin converters are currently experimental
error: could not generate output program: invalid Go source code:

package main

import (
"fmt"

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/appautoscaling"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/rds"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func notImplemented(message string) pulumi.AnyOutput {
    panic(message)
}

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
// Whether cluster should be created (affects nearly all resources)
create := true;
if param := cfg.GetBool("create"); param {
create = param
}
// Name used across resources created
name := "";
if param := cfg.Get("name"); param != ""{
name = param
}
// A map of tags to add to all resources
tags := nil;
if param := cfg.GetBool("tags"); param != nil {
tags = param
}
// Determines whether to create the database subnet group or use existing
createDbSubnetGroup := false;
if param := cfg.GetBool("createDbSubnetGroup"); param {
createDbSubnetGroup = param
}
// The name of the subnet group name (existing or created)
dbSubnetGroupName := "";
if param := cfg.Get("dbSubnetGroupName"); param != ""{
dbSubnetGroupName = param
}
// List of subnet IDs used by database subnet group created
subnets := []interface{}{
};
if param := cfg.GetBool("subnets"); param != nil {
subnets = param
}
// Determines whether cluster is primary cluster with writer instance (set to `false` for global cluster and replica clusters)
isPrimaryCluster := true;
if param := cfg.GetBool("isPrimaryCluster"); param {
isPrimaryCluster = param
}
// Whether to use `name` as a prefix for the cluster
clusterUseNamePrefix := false;
if param := cfg.GetBool("clusterUseNamePrefix"); param {
clusterUseNamePrefix = param
}
// The amount of storage in gibibytes (GiB) to allocate to each DB instance in the Multi-AZ DB cluster. (This setting is required to create a Multi-AZ DB cluster)
allocatedStorage := nil;
if param := cfg.GetBool("allocatedStorage"); param != nil {
allocatedStorage = param
}
// Enable to allow major engine version upgrades when changing engine versions. Defaults to `false`
allowMajorVersionUpgrade := false;
if param := cfg.GetBool("allowMajorVersionUpgrade"); param {
allowMajorVersionUpgrade = param
}
// Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. Default is `false`
applyImmediately := nil;
if param := cfg.GetBool("applyImmediately"); param != nil {
applyImmediately = param
}
// List of EC2 Availability Zones for the DB cluster storage where DB cluster instances can be created. RDS automatically assigns 3 AZs if less than 3 AZs are configured, which will show as a difference requiring resource recreation next Terraform apply
availabilityZones := nil;
if param := cfg.GetBool("availabilityZones"); param != nil {
availabilityZones = param
}
// The days to retain backups for. Default `7`
backupRetentionPeriod := float64(7);
if param := cfg.GetFloat64("backupRetentionPeriod"); param != 0 {
backupRetentionPeriod = param
}
// The target backtrack window, in seconds. Only available for `aurora` engine currently. To disable backtracking, set this value to 0. Must be between 0 and 259200 (72 hours)
backtrackWindow := nil;
if param := cfg.GetBool("backtrackWindow"); param != nil {
backtrackWindow = param
}
// List of RDS Instances that are a part of this cluster
clusterMembers := nil;
if param := cfg.GetBool("clusterMembers"); param != nil {
clusterMembers = param
}
// Copy all Cluster `tags` to snapshots
copyTagsToSnapshot := nil;
if param := cfg.GetBool("copyTagsToSnapshot"); param != nil {
copyTagsToSnapshot = param
}
// Name for an automatically created database on cluster creation
databaseName := nil;
if param := cfg.GetBool("databaseName"); param != nil {
databaseName = param
}
// The compute and memory capacity of each DB instance in the Multi-AZ DB cluster, for example db.m6g.xlarge. Not all DB instance classes are available in all AWS Regions, or for all database engines
dbClusterInstanceClass := nil;
if param := cfg.GetBool("dbClusterInstanceClass"); param != nil {
dbClusterInstanceClass = param
}
// Instance parameter group to associate with all instances of the DB cluster. The `db_cluster_db_instance_parameter_group_name` is only valid in combination with `allow_major_version_upgrade`
dbClusterDbInstanceParameterGroupName := nil;
if param := cfg.GetBool("dbClusterDbInstanceParameterGroupName"); param != nil {
dbClusterDbInstanceParameterGroupName = param
}
// If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to `true`. The default is `false`
deletionProtection := nil;
if param := cfg.GetBool("deletionProtection"); param != nil {
deletionProtection = param
}
// Whether cluster should forward writes to an associated global cluster. Applied to secondary clusters to enable them to forward writes to an `aws_rds_global_cluster`'s primary cluster
enableGlobalWriteForwarding := nil;
if param := cfg.GetBool("enableGlobalWriteForwarding"); param != nil {
enableGlobalWriteForwarding = param
}
// Set of log types to export to cloudwatch. If omitted, no logs will be exported. The following log types are supported: `audit`, `error`, `general`, `slowquery`, `postgresql`
enabledCloudwatchLogsExports := []interface{}{
};
if param := cfg.GetBool("enabledCloudwatchLogsExports"); param != nil {
enabledCloudwatchLogsExports = param
}
// Enable HTTP endpoint (data API). Only valid when engine_mode is set to `serverless`
enableHttpEndpoint := nil;
if param := cfg.GetBool("enableHttpEndpoint"); param != nil {
enableHttpEndpoint = param
}
// The name of the database engine to be used for this DB cluster. Defaults to `aurora`. Valid Values: `aurora`, `aurora-mysql`, `aurora-postgresql`
engine := nil;
if param := cfg.GetBool("engine"); param != nil {
engine = param
}
// The database engine mode. Valid values: `global`, `multimaster`, `parallelquery`, `provisioned`, `serverless`. Defaults to: `provisioned`
engineMode := "provisioned";
if param := cfg.Get("engineMode"); param != ""{
engineMode = param
}
// The database engine version. Updating this argument results in an outage
engineVersion := nil;
if param := cfg.GetBool("engineVersion"); param != nil {
engineVersion = param
}
// The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made
finalSnapshotIdentifier := nil;
if param := cfg.GetBool("finalSnapshotIdentifier"); param != nil {
finalSnapshotIdentifier = param
}
// The global cluster identifier specified on `aws_rds_global_cluster`
globalClusterIdentifier := nil;
if param := cfg.GetBool("globalClusterIdentifier"); param != nil {
globalClusterIdentifier = param
}
// Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled
iamDatabaseAuthenticationEnabled := nil;
if param := cfg.GetBool("iamDatabaseAuthenticationEnabled"); param != nil {
iamDatabaseAuthenticationEnabled = param
}
// The amount of Provisioned IOPS (input/output operations per second) to be initially allocated for each DB instance in the Multi-AZ DB cluster
iops := nil;
if param := cfg.GetBool("iops"); param != nil {
iops = param
}
// The ARN for the KMS encryption key. When specifying `kms_key_id`, `storage_encrypted` needs to be set to `true`
kmsKeyId := nil;
if param := cfg.GetBool("kmsKeyId"); param != nil {
kmsKeyId = param
}
// Set to true to allow RDS to manage the master user password in Secrets Manager. Cannot be set if `master_password` is provided
manageMasterUserPassword := true;
if param := cfg.GetBool("manageMasterUserPassword"); param {
manageMasterUserPassword = param
}
// The Amazon Web Services KMS key identifier is the key ARN, key ID, alias ARN, or alias name for the KMS key
masterUserSecretKmsKeyId := nil;
if param := cfg.GetBool("masterUserSecretKmsKeyId"); param != nil {
masterUserSecretKmsKeyId = param
}
// Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. Required unless `manage_master_user_password` is set to `true` or unless `snapshot_identifier` or `replication_source_identifier` is provided or unless a `global_cluster_identifier` is provided when the cluster is the secondary cluster of a global database
masterPassword := nil;
if param := cfg.GetBool("masterPassword"); param != nil {
masterPassword = param
}
// Username for the master DB user. Required unless `snapshot_identifier` or `replication_source_identifier` is provided or unless a `global_cluster_identifier` is provided when the cluster is the secondary cluster of a global database
masterUsername := nil;
if param := cfg.GetBool("masterUsername"); param != nil {
masterUsername = param
}
// The type of network stack to use (IPV4 or DUAL)
networkType := nil;
if param := cfg.GetBool("networkType"); param != nil {
networkType = param
}
// The port on which the DB accepts connections
port := nil;
if param := cfg.GetBool("port"); param != nil {
port = param
}
// The daily time range during which automated backups are created if automated backups are enabled using the `backup_retention_period` parameter. Time in UTC
preferredBackupWindow := "02:00-03:00";
if param := cfg.Get("preferredBackupWindow"); param != ""{
preferredBackupWindow = param
}
// The weekly time range during which system maintenance can occur, in (UTC)
preferredMaintenanceWindow := "sun:05:00-sun:06:00";
if param := cfg.Get("preferredMaintenanceWindow"); param != ""{
preferredMaintenanceWindow = param
}
// ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica
replicationSourceIdentifier := nil;
if param := cfg.GetBool("replicationSourceIdentifier"); param != nil {
replicationSourceIdentifier = param
}
// Map of nested attributes for cloning Aurora cluster
restoreToPointInTime := nil;
if param := cfg.GetBool("restoreToPointInTime"); param != nil {
restoreToPointInTime = param
}
// Configuration map used to restore from a Percona Xtrabackup in S3 (only MySQL is supported)
s3Import := nil;
if param := cfg.GetBool("s3Import"); param != nil {
s3Import = param
}
// Map of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless`
scalingConfiguration := nil;
if param := cfg.GetBool("scalingConfiguration"); param != nil {
scalingConfiguration = param
}
// Map of nested attributes with serverless v2 scaling properties. Only valid when `engine_mode` is set to `provisioned`
serverlessv2ScalingConfiguration := nil;
if param := cfg.GetBool("serverlessv2ScalingConfiguration"); param != nil {
serverlessv2ScalingConfiguration = param
}
// Determines whether a final snapshot is created before the cluster is deleted. If true is specified, no snapshot is created
skipFinalSnapshot := false;
if param := cfg.GetBool("skipFinalSnapshot"); param {
skipFinalSnapshot = param
}
// Specifies whether or not to create this cluster from a snapshot. You can use either the name or ARN when specifying a DB cluster snapshot, or the ARN when specifying a DB snapshot
snapshotIdentifier := nil;
if param := cfg.GetBool("snapshotIdentifier"); param != nil {
snapshotIdentifier = param
}
// The source region for an encrypted replica DB cluster
sourceRegion := nil;
if param := cfg.GetBool("sourceRegion"); param != nil {
sourceRegion = param
}
// Specifies whether the DB cluster is encrypted. The default is `true`
storageEncrypted := true;
if param := cfg.GetBool("storageEncrypted"); param {
storageEncrypted = param
}
// Specifies the storage type to be associated with the DB cluster. (This setting is required to create a Multi-AZ DB cluster). Valid values: `io1`, Default: `io1`
storageType := nil;
if param := cfg.GetBool("storageType"); param != nil {
storageType = param
}
// A map of tags to add to only the cluster. Used for AWS Instance Scheduler tagging
clusterTags := nil;
if param := cfg.GetBool("clusterTags"); param != nil {
clusterTags = param
}
// List of VPC security groups to associate to the cluster in addition to the security group created
vpcSecurityGroupIds := []interface{}{
};
if param := cfg.GetBool("vpcSecurityGroupIds"); param != nil {
vpcSecurityGroupIds = param
}
// Create, update, and delete timeout configurations for the cluster
clusterTimeouts := nil;
if param := cfg.GetBool("clusterTimeouts"); param != nil {
clusterTimeouts = param
}
// Map of cluster instances and any specific/overriding attributes to be created
instances := nil;
if param := cfg.GetBool("instances"); param != nil {
instances = param
}
// Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Default `true`
autoMinorVersionUpgrade := nil;
if param := cfg.GetBool("autoMinorVersionUpgrade"); param != nil {
autoMinorVersionUpgrade = param
}
// The identifier of the CA certificate for the DB instance
caCertIdentifier := nil;
if param := cfg.GetBool("caCertIdentifier"); param != nil {
caCertIdentifier = param
}
// The name of the DB parameter group
dbParameterGroupName := nil;
if param := cfg.GetBool("dbParameterGroupName"); param != nil {
dbParameterGroupName = param
}
// Determines whether cluster instance identifiers are used as prefixes
instancesUseIdentifierPrefix := false;
if param := cfg.GetBool("instancesUseIdentifierPrefix"); param {
instancesUseIdentifierPrefix = param
}
// Instance type to use at master instance. Note: if `autoscaling_enabled` is `true`, this will be the same instance class used on instances created by autoscaling
instanceClass := "";
if param := cfg.Get("instanceClass"); param != ""{
instanceClass = param
}
// The interval, in seconds, between points when Enhanced Monitoring metrics are collected for instances. Set to `0` to disable. Default is `0`
monitoringInterval := float64(0);
if param := cfg.GetFloat64("monitoringInterval"); param != 0 {
monitoringInterval = param
}
// Specifies whether Performance Insights is enabled or not
performanceInsightsEnabled := nil;
if param := cfg.GetBool("performanceInsightsEnabled"); param != nil {
performanceInsightsEnabled = param
}
// The ARN for the KMS key to encrypt Performance Insights data
performanceInsightsKmsKeyId := nil;
if param := cfg.GetBool("performanceInsightsKmsKeyId"); param != nil {
performanceInsightsKmsKeyId = param
}
// Amount of time in days to retain Performance Insights data. Either 7 (7 days) or 731 (2 years)
performanceInsightsRetentionPeriod := nil;
if param := cfg.GetBool("performanceInsightsRetentionPeriod"); param != nil {
performanceInsightsRetentionPeriod = param
}
// Determines whether instances are publicly accessible. Default `false`
publiclyAccessible := nil;
if param := cfg.GetBool("publiclyAccessible"); param != nil {
publiclyAccessible = param
}
// Create, update, and delete timeout configurations for the cluster instance(s)
instanceTimeouts := nil;
if param := cfg.GetBool("instanceTimeouts"); param != nil {
instanceTimeouts = param
}
// Map of additional cluster endpoints and their attributes to be created
endpoints := nil;
if param := cfg.GetBool("endpoints"); param != nil {
endpoints = param
}
// Map of IAM roles and supported feature names to associate with the cluster
iamRoles := nil;
if param := cfg.GetBool("iamRoles"); param != nil {
iamRoles = param
}
// Determines whether to create the IAM role for RDS enhanced monitoring
createMonitoringRole := true;
if param := cfg.GetBool("createMonitoringRole"); param {
createMonitoringRole = param
}
// IAM role used by RDS to send enhanced monitoring metrics to CloudWatch
monitoringRoleArn := "";
if param := cfg.Get("monitoringRoleArn"); param != ""{
monitoringRoleArn = param
}
// Friendly name of the monitoring role
iamRoleName := nil;
if param := cfg.GetBool("iamRoleName"); param != nil {
iamRoleName = param
}
// Determines whether to use `iam_role_name` as is or create a unique name beginning with the `iam_role_name` as the prefix
iamRoleUseNamePrefix := false;
if param := cfg.GetBool("iamRoleUseNamePrefix"); param {
iamRoleUseNamePrefix = param
}
// Description of the monitoring role
iamRoleDescription := nil;
if param := cfg.GetBool("iamRoleDescription"); param != nil {
iamRoleDescription = param
}
// Path for the monitoring role
iamRolePath := nil;
if param := cfg.GetBool("iamRolePath"); param != nil {
iamRolePath = param
}
// Set of exclusive IAM managed policy ARNs to attach to the monitoring role
iamRoleManagedPolicyArns := nil;
if param := cfg.GetBool("iamRoleManagedPolicyArns"); param != nil {
iamRoleManagedPolicyArns = param
}
// The ARN of the policy that is used to set the permissions boundary for the monitoring role
iamRolePermissionsBoundary := nil;
if param := cfg.GetBool("iamRolePermissionsBoundary"); param != nil {
iamRolePermissionsBoundary = param
}
// Whether to force detaching any policies the monitoring role has before destroying it
iamRoleForceDetachPolicies := nil;
if param := cfg.GetBool("iamRoleForceDetachPolicies"); param != nil {
iamRoleForceDetachPolicies = param
}
// Maximum session duration (in seconds) that you want to set for the monitoring role
iamRoleMaxSessionDuration := nil;
if param := cfg.GetBool("iamRoleMaxSessionDuration"); param != nil {
iamRoleMaxSessionDuration = param
}
// Determines whether autoscaling of the cluster read replicas is enabled
autoscalingEnabled := false;
if param := cfg.GetBool("autoscalingEnabled"); param {
autoscalingEnabled = param
}
// Maximum number of read replicas permitted when autoscaling is enabled
autoscalingMaxCapacity := float64(2);
if param := cfg.GetFloat64("autoscalingMaxCapacity"); param != 0 {
autoscalingMaxCapacity = param
}
// Minimum number of read replicas permitted when autoscaling is enabled
autoscalingMinCapacity := float64(0);
if param := cfg.GetFloat64("autoscalingMinCapacity"); param != 0 {
autoscalingMinCapacity = param
}
// Autoscaling policy name
autoscalingPolicyName := "target-metric";
if param := cfg.Get("autoscalingPolicyName"); param != ""{
autoscalingPolicyName = param
}
// The metric type to scale on. Valid values are `RDSReaderAverageCPUUtilization` and `RDSReaderAverageDatabaseConnections`
predefinedMetricType := "RDSReaderAverageCPUUtilization";
if param := cfg.Get("predefinedMetricType"); param != ""{
predefinedMetricType = param
}
// Cooldown in seconds before allowing further scaling operations after a scale in
autoscalingScaleInCooldown := float64(300);
if param := cfg.GetFloat64("autoscalingScaleInCooldown"); param != 0 {
autoscalingScaleInCooldown = param
}
// Cooldown in seconds before allowing further scaling operations after a scale out
autoscalingScaleOutCooldown := float64(300);
if param := cfg.GetFloat64("autoscalingScaleOutCooldown"); param != 0 {
autoscalingScaleOutCooldown = param
}
// CPU threshold which will initiate autoscaling
autoscalingTargetCpu := float64(70);
if param := cfg.GetFloat64("autoscalingTargetCpu"); param != 0 {
autoscalingTargetCpu = param
}
// Average number of connections threshold which will initiate autoscaling. Default value is 70% of db.r4/r5/r6g.large's default max_connections
autoscalingTargetConnections := float64(700);
if param := cfg.GetFloat64("autoscalingTargetConnections"); param != 0 {
autoscalingTargetConnections = param
}
// Determines whether to create security group for RDS cluster
createSecurityGroup := true;
if param := cfg.GetBool("createSecurityGroup"); param {
createSecurityGroup = param
}
// Determines whether the security group name (`var.name`) is used as a prefix
securityGroupUseNamePrefix := true;
if param := cfg.GetBool("securityGroupUseNamePrefix"); param {
securityGroupUseNamePrefix = param
}
// The description of the security group. If value is set to empty string it will contain cluster name in the description
securityGroupDescription := nil;
if param := cfg.GetBool("securityGroupDescription"); param != nil {
securityGroupDescription = param
}
// ID of the VPC where to create security group
vpcId := "";
if param := cfg.Get("vpcId"); param != ""{
vpcId = param
}
// Map of security group rules to add to the cluster security group created
securityGroupRules := nil;
if param := cfg.GetBool("securityGroupRules"); param != nil {
securityGroupRules = param
}
// Additional tags for the security group
securityGroupTags := nil;
if param := cfg.GetBool("securityGroupTags"); param != nil {
securityGroupTags = param
}
// Determines whether a cluster parameter should be created or use existing
createDbClusterParameterGroup := false;
if param := cfg.GetBool("createDbClusterParameterGroup"); param {
createDbClusterParameterGroup = param
}
// The name of the DB cluster parameter group
dbClusterParameterGroupName := nil;
if param := cfg.GetBool("dbClusterParameterGroupName"); param != nil {
dbClusterParameterGroupName = param
}
// Determines whether the DB cluster parameter group name is used as a prefix
dbClusterParameterGroupUseNamePrefix := true;
if param := cfg.GetBool("dbClusterParameterGroupUseNamePrefix"); param {
dbClusterParameterGroupUseNamePrefix = param
}
// The description of the DB cluster parameter group. Defaults to "Managed by Terraform"
dbClusterParameterGroupDescription := nil;
if param := cfg.GetBool("dbClusterParameterGroupDescription"); param != nil {
dbClusterParameterGroupDescription = param
}
// The family of the DB cluster parameter group
dbClusterParameterGroupFamily := "";
if param := cfg.Get("dbClusterParameterGroupFamily"); param != ""{
dbClusterParameterGroupFamily = param
}
// A list of DB cluster parameters to apply. Note that parameters may differ from a family to an other
dbClusterParameterGroupParameters := []interface{}{
};
if param := cfg.GetBool("dbClusterParameterGroupParameters"); param != nil {
dbClusterParameterGroupParameters = param
}
// Determines whether a DB parameter should be created or use existing
createDbParameterGroup := false;
if param := cfg.GetBool("createDbParameterGroup"); param {
createDbParameterGroup = param
}
// Determines whether the DB parameter group name is used as a prefix
dbParameterGroupUseNamePrefix := true;
if param := cfg.GetBool("dbParameterGroupUseNamePrefix"); param {
dbParameterGroupUseNamePrefix = param
}
// The description of the DB parameter group. Defaults to "Managed by Terraform"
dbParameterGroupDescription := nil;
if param := cfg.GetBool("dbParameterGroupDescription"); param != nil {
dbParameterGroupDescription = param
}
// The family of the DB parameter group
dbParameterGroupFamily := "";
if param := cfg.Get("dbParameterGroupFamily"); param != ""{
dbParameterGroupFamily = param
}
// A list of DB parameters to apply. Note that parameters may differ from a family to an other
dbParameterGroupParameters := []interface{}{
};
if param := cfg.GetBool("dbParameterGroupParameters"); param != nil {
dbParameterGroupParameters = param
}
// Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!
putinKhuylo := true;
if param := cfg.GetBool("putinKhuylo"); param {
putinKhuylo = param
}
// Determines whether a CloudWatch log group is created for each `enabled_cloudwatch_logs_exports`
createCloudwatchLogGroup := false;
if param := cfg.GetBool("createCloudwatchLogGroup"); param {
createCloudwatchLogGroup = param
}
// The number of days to retain CloudWatch logs for the DB instance
cloudwatchLogGroupRetentionInDays := float64(7);
if param := cfg.GetFloat64("cloudwatchLogGroupRetentionInDays"); param != 0 {
cloudwatchLogGroupRetentionInDays = param
}
// The ARN of the KMS Key to use when encrypting log data
cloudwatchLogGroupKmsKeyId := nil;
if param := cfg.GetBool("cloudwatchLogGroupKmsKeyId"); param != nil {
cloudwatchLogGroupKmsKeyId = param
}
current, err := aws.GetPartition(ctx, nil, nil);
if err != nil {
return err
}
mycreate := create && putinKhuylo;
myport := notImplemented("coalesce(var.port,(var.engine==\"aurora-postgresql\"||var.engine==\"postgres\"?5432:3306))");
internalDbSubnetGroupName := notImplemented("try(coalesce(var.db_subnet_group_name,var.name),\"\")");
var tmp0 interface{}
if createDbSubnetGroup {
tmp0 = notImplemented("try(aws_db_subnet_group.this[0].name,null)")
} else {
tmp0 = internalDbSubnetGroupName
}
mydbSubnetGroupName := tmp0;
clusterParameterGroupName := notImplemented("try(coalesce(var.db_cluster_parameter_group_name,var.name),null)");
mydbParameterGroupName := notImplemented("try(coalesce(var.db_parameter_group_name,var.name),null)");
var tmp1 *float64
if (engine == "aurora-mysql" || engine == "aurora") && engineMode != "serverless" {
tmp1 = backtrackWindow
} else {
tmp1 = 0
}
mybacktrackWindow := tmp1;
isServerless := engineMode == "serverless";
var tmp2 float64
if mycreate && createDbSubnetGroup {
tmp2 = 1
} else {
tmp2 = 0
}
var this []*rds.SubnetGroup
for index := 0; index < tmp2; index++ {
    key0 := index
    _ := index
__res, err := rds.NewSubnetGroup(ctx, fmt.Sprintf("this-%v", key0), &rds.SubnetGroupArgs{
Name: pulumi.Any(internalDbSubnetGroupName),
Description: pulumi.String(fmt.Sprintf("For Aurora cluster %v", name)),
SubnetIds: subnets,
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
this = append(this, __res)
}
var tmp3 pulumi.String
if dbClusterParameterGroupUseNamePrefix {
tmp3 = nil
} else {
tmp3 = pulumi.Any(clusterParameterGroupName)
}
var tmp4 pulumi.String
if dbClusterParameterGroupUseNamePrefix {
tmp4 = pulumi.String(fmt.Sprintf("%v-", clusterParameterGroupName))
} else {
tmp4 = nil
}
var tmp5 float64
if mycreate && createDbClusterParameterGroup {
tmp5 = 1
} else {
tmp5 = 0
}
var thisResource9 []*rds.ClusterParameterGroup
for index := 0; index < tmp5; index++ {
    key0 := index
    _ := index
__res, err := rds.NewClusterParameterGroup(ctx, fmt.Sprintf("thisResource9-%v", key0), &rds.ClusterParameterGroupArgs{
Parameters: "TODO: For expression",
Name: pulumi.String(tmp3),
NamePrefix: pulumi.String(tmp4),
Description: *pulumi.String(dbClusterParameterGroupDescription),
Family: pulumi.String(dbClusterParameterGroupFamily),
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
thisResource9 = append(thisResource9, __res)
}
var tmp6 pulumi.String
if clusterUseNamePrefix {
tmp6 = nil
} else {
tmp6 = pulumi.String(name)
}
var tmp7 pulumi.String
if clusterUseNamePrefix {
tmp7 = pulumi.String(fmt.Sprintf("%v-", name))
} else {
tmp7 = nil
}
var tmp8 pulumi.String
if isPrimaryCluster {
tmp8 = *pulumi.String(databaseName)
} else {
tmp8 = nil
}
var tmp9 pulumi.String
if createDbClusterParameterGroup {
tmp9 = thisResource9[0].ID()
} else {
tmp9 = *pulumi.String(dbClusterParameterGroupName)
}
var tmp10 pulumi.String
if allowMajorVersionUpgrade {
tmp10 = *pulumi.String(dbClusterDbInstanceParameterGroupName)
} else {
tmp10 = nil
}
var tmp11 pulumi.Bool
if globalClusterIdentifier == nil && manageMasterUserPassword {
tmp11 = pulumi.Bool(manageMasterUserPassword)
} else {
tmp11 = nil
}
var tmp12 pulumi.String
if globalClusterIdentifier == nil && manageMasterUserPassword {
tmp12 = *pulumi.String(masterUserSecretKmsKeyId)
} else {
tmp12 = nil
}
var tmp13 pulumi.String
if isPrimaryCluster && !manageMasterUserPassword {
tmp13 = *pulumi.String(masterPassword)
} else {
tmp13 = nil
}
var tmp14 pulumi.String
if isPrimaryCluster {
tmp14 = *pulumi.String(masterUsername)
} else {
tmp14 = nil
}
var tmp15 pulumi.String
if isServerless {
tmp15 = nil
} else {
tmp15 = pulumi.String(preferredBackupWindow)
}
var tmp16 pulumi.String
if isServerless {
tmp16 = nil
} else {
tmp16 = pulumi.String(preferredMaintenanceWindow)
}
var tmp17 float64
if mycreate {
tmp17 = 1
} else {
tmp17 = 0
}
var thisResource []*rds.Cluster
for index := 0; index < tmp17; index++ {
    key0 := index
    _ := index
__res, err := rds.NewCluster(ctx, fmt.Sprintf("thisResource-%v", key0), &rds.ClusterArgs{
S3Import: "TODO: For expression"[0],
ScalingConfiguration: "TODO: For expression"[0],
Serverlessv2ScalingConfiguration: "TODO: For expression"[0],
RestoreToPointInTime: "TODO: For expression"[0],
AllocatedStorage: *pulumi.Float64(allocatedStorage),
AllowMajorVersionUpgrade: pulumi.Bool(allowMajorVersionUpgrade),
ApplyImmediately: *pulumi.Bool(applyImmediately),
AvailabilityZones: interface{}(availabilityZones),
BackupRetentionPeriod: pulumi.Float64(backupRetentionPeriod),
BacktrackWindow: *pulumi.Float64(mybacktrackWindow),
ClusterIdentifier: pulumi.String(tmp6),
ClusterIdentifierPrefix: pulumi.String(tmp7),
ClusterMembers: interface{}(clusterMembers),
CopyTagsToSnapshot: *pulumi.Bool(copyTagsToSnapshot),
DatabaseName: pulumi.String(tmp8),
DbClusterInstanceClass: *pulumi.String(dbClusterInstanceClass),
DbClusterParameterGroupName: pulumi.String(tmp9),
DbInstanceParameterGroupName: pulumi.String(tmp10),
DbSubnetGroupName: pulumi.Any(mydbSubnetGroupName),
DeletionProtection: *pulumi.Bool(deletionProtection),
EnableGlobalWriteForwarding: *pulumi.Bool(enableGlobalWriteForwarding),
EnabledCloudwatchLogsExports: enabledCloudwatchLogsExports,
EnableHttpEndpoint: *pulumi.Bool(enableHttpEndpoint),
Engine: rds.EngineType(engine),
EngineMode: pulumi.String(engineMode),
EngineVersion: *pulumi.String(engineVersion),
FinalSnapshotIdentifier: *pulumi.String(finalSnapshotIdentifier),
GlobalClusterIdentifier: *pulumi.String(globalClusterIdentifier),
IamDatabaseAuthenticationEnabled: *pulumi.Bool(iamDatabaseAuthenticationEnabled),
Iops: *pulumi.Float64(iops),
KmsKeyId: *pulumi.String(kmsKeyId),
ManageMasterUserPassword: pulumi.Bool(tmp11),
MasterUserSecretKmsKeyId: pulumi.String(tmp12),
MasterPassword: pulumi.String(tmp13),
MasterUsername: pulumi.String(tmp14),
NetworkType: *pulumi.String(networkType),
Port: pulumi.Any(myport),
PreferredBackupWindow: pulumi.String(tmp15),
PreferredMaintenanceWindow: pulumi.String(tmp16),
ReplicationSourceIdentifier: *pulumi.String(replicationSourceIdentifier),
SkipFinalSnapshot: pulumi.Bool(skipFinalSnapshot),
SnapshotIdentifier: *pulumi.String(snapshotIdentifier),
SourceRegion: *pulumi.String(sourceRegion),
StorageEncrypted: pulumi.Bool(storageEncrypted),
StorageType: *pulumi.String(storageType),
Tags: notImplemented("merge(var.tags,var.cluster_tags)"),
VpcSecurityGroupIds: notImplemented("compact(concat([try(aws_security_group.this[0].id,\"\")],var.vpc_security_group_ids))"),
})
if err != nil {
return err
}
thisResource = append(thisResource, __res)
}
var tmp18 pulumi.String
if dbParameterGroupUseNamePrefix {
tmp18 = nil
} else {
tmp18 = pulumi.Any(mydbParameterGroupName)
}
var tmp19 pulumi.String
if dbParameterGroupUseNamePrefix {
tmp19 = pulumi.String(fmt.Sprintf("%v-", mydbParameterGroupName))
} else {
tmp19 = nil
}
var tmp20 float64
if mycreate && createDbParameterGroup {
tmp20 = 1
} else {
tmp20 = 0
}
var thisResource10 []*rds.ParameterGroup
for index := 0; index < tmp20; index++ {
    key0 := index
    _ := index
__res, err := rds.NewParameterGroup(ctx, fmt.Sprintf("thisResource10-%v", key0), &rds.ParameterGroupArgs{
Parameters: "TODO: For expression",
Name: pulumi.String(tmp18),
NamePrefix: pulumi.String(tmp19),
Description: *pulumi.String(dbParameterGroupDescription),
Family: pulumi.String(dbParameterGroupFamily),
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
thisResource10 = append(thisResource10, __res)
}
var tmp21 pulumi.String
if createDbParameterGroup {
tmp21 = thisResource10[0].ID()
} else {
tmp21 = *pulumi.String(dbParameterGroupName)
}
var tmp22 pulumi.String
if instancesUseIdentifierPrefix {
tmp22 = nil
} else {
tmp22 = notImplemented("try(each.value.identifier,\"${var.name}-${each.key}\")")
}
var tmp23 pulumi.String
if instancesUseIdentifierPrefix {
tmp23 = notImplemented("try(each.value.identifier_prefix,\"${var.name}-${each.key}-\")")
} else {
tmp23 = nil
}
var tmp24 pulumi.String
if createMonitoringRole {
tmp24 = notImplemented("try(aws_iam_role.rds_enhanced_monitoring[0].arn,null)")
} else {
tmp24 = pulumi.String(monitoringRoleArn)
}
var thisResource2 []*rds.ClusterInstance
for key0, _ := range "TODO: For expression" {
__res, err := rds.NewClusterInstance(ctx, fmt.Sprintf("thisResource2-%v", key0), &rds.ClusterInstanceArgs{
ApplyImmediately: notImplemented("try(each.value.apply_immediately,var.apply_immediately)"),
AutoMinorVersionUpgrade: notImplemented("try(each.value.auto_minor_version_upgrade,var.auto_minor_version_upgrade)"),
AvailabilityZone: notImplemented("try(each.value.availability_zone,null)"),
CaCertIdentifier: *pulumi.String(caCertIdentifier),
ClusterIdentifier: thisResource[0].ID(),
CopyTagsToSnapshot: notImplemented("try(each.value.copy_tags_to_snapshot,var.copy_tags_to_snapshot)"),
DbParameterGroupName: pulumi.String(tmp21),
DbSubnetGroupName: pulumi.Any(mydbSubnetGroupName),
Engine: *pulumi.String(engine),
EngineVersion: *pulumi.String(engineVersion),
Identifier: pulumi.String(tmp22),
IdentifierPrefix: pulumi.String(tmp23),
InstanceClass: rds.InstanceType(notImplemented("try(each.value.instance_class,var.instance_class)")),
MonitoringInterval: notImplemented("try(each.value.monitoring_interval,var.monitoring_interval)"),
MonitoringRoleArn: pulumi.String(tmp24),
PerformanceInsightsEnabled: notImplemented("try(each.value.performance_insights_enabled,var.performance_insights_enabled)"),
PerformanceInsightsKmsKeyId: notImplemented("try(each.value.performance_insights_kms_key_id,var.performance_insights_kms_key_id)"),
PerformanceInsightsRetentionPeriod: notImplemented("try(each.value.performance_insights_retention_period,var.performance_insights_retention_period)"),
PreferredMaintenanceWindow: notImplemented("try(each.value.preferred_maintenance_window,var.preferred_maintenance_window)"),
PromotionTier: notImplemented("try(each.value.promotion_tier,null)"),
PubliclyAccessible: notImplemented("try(each.value.publicly_accessible,var.publicly_accessible)"),
Tags: notImplemented("merge(var.tags,try(each.value.tags,{}))"),
})
if err != nil {
return err
}
thisResource2 = append(thisResource2, __res)
}
var thisResource3 []*rds.ClusterEndpoint
for key0, val0 := range "TODO: For expression" {
__res, err := rds.NewClusterEndpoint(ctx, fmt.Sprintf("thisResource3-%v", key0), &rds.ClusterEndpointArgs{
ClusterEndpointIdentifier: pulumi.Any(val0),
ClusterIdentifier: thisResource[0].ID(),
CustomEndpointType: pulumi.Any(val0),
ExcludedMembers: notImplemented("try(each.value.excluded_members,null)"),
StaticMembers: notImplemented("try(each.value.static_members,null)"),
Tags: notImplemented("merge(var.tags,try(each.value.tags,{}))"),
})
if err != nil {
return err
}
thisResource3 = append(thisResource3, __res)
}
var thisResource4 []*rds.ClusterRoleAssociation
for key0, val0 := range "TODO: For expression" {
__res, err := rds.NewClusterRoleAssociation(ctx, fmt.Sprintf("thisResource4-%v", key0), &rds.ClusterRoleAssociationArgs{
DbClusterIdentifier: thisResource[0].ID(),
FeatureName: pulumi.String(val0),
RoleArn: pulumi.String(val0),
})
if err != nil {
return err
}
thisResource4 = append(thisResource4, __res)
}
mycreateMonitoringRole := mycreate && createMonitoringRole && monitoringInterval > 0;
monitoringRdsAssumeRole := "TODO: For expression";
var tmp25 pulumi.String
if iamRoleUseNamePrefix {
tmp25 = nil
} else {
tmp25 = *pulumi.String(iamRoleName)
}
var tmp26 pulumi.String
if iamRoleUseNamePrefix {
tmp26 = pulumi.String(fmt.Sprintf("%v-", iamRoleName))
} else {
tmp26 = nil
}
var tmp27 float64
if mycreateMonitoringRole {
tmp27 = 1
} else {
tmp27 = 0
}
var rdsEnhancedMonitoring []*iam.Role
for index := 0; index < tmp27; index++ {
    key0 := index
    _ := index
__res, err := iam.NewRole(ctx, fmt.Sprintf("rdsEnhancedMonitoring-%v", key0), &iam.RoleArgs{
Name: pulumi.String(tmp25),
NamePrefix: pulumi.String(tmp26),
Description: *pulumi.String(iamRoleDescription),
Path: *pulumi.String(iamRolePath),
AssumeRolePolicy: pulumi.String(monitoringRdsAssumeRole[0].Json),
ManagedPolicyArns: interface{}(iamRoleManagedPolicyArns),
PermissionsBoundary: *pulumi.String(iamRolePermissionsBoundary),
ForceDetachPolicies: *pulumi.Bool(iamRoleForceDetachPolicies),
MaxSessionDuration: *pulumi.Float64(iamRoleMaxSessionDuration),
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
rdsEnhancedMonitoring = append(rdsEnhancedMonitoring, __res)
}
var tmp28 float64
if mycreateMonitoringRole {
tmp28 = 1
} else {
tmp28 = 0
}
var rdsEnhancedMonitoringResource []*iam.RolePolicyAttachment
for index := 0; index < tmp28; index++ {
    key0 := index
    _ := index
__res, err := iam.NewRolePolicyAttachment(ctx, fmt.Sprintf("rdsEnhancedMonitoringResource-%v", key0), &iam.RolePolicyAttachmentArgs{
Role: rdsEnhancedMonitoring[0].Name,
PolicyArn: pulumi.String(fmt.Sprintf("arn:%v:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole", current.Partition)),
})
if err != nil {
return err
}
rdsEnhancedMonitoringResource = append(rdsEnhancedMonitoringResource, __res)
}
var tmp29 float64
if mycreate && autoscalingEnabled && !isServerless {
tmp29 = 1
} else {
tmp29 = 0
}
var thisResource5 []*appautoscaling.Target
for index := 0; index < tmp29; index++ {
    key0 := index
    _ := index
__res, err := appautoscaling.NewTarget(ctx, fmt.Sprintf("thisResource5-%v", key0), &appautoscaling.TargetArgs{
MaxCapacity: pulumi.Float64(autoscalingMaxCapacity),
MinCapacity: pulumi.Float64(autoscalingMinCapacity),
ResourceId: thisResource[0].ClusterIdentifier.ApplyT(func(clusterIdentifier string) (string, error) {
return fmt.Sprintf("cluster:%v", clusterIdentifier), nil
}).(pulumi.StringOutput),
ScalableDimension: pulumi.String("rds:cluster:ReadReplicaCount"),
ServiceNamespace: pulumi.String("rds"),
})
if err != nil {
return err
}
thisResource5 = append(thisResource5, __res)
}
var tmp30 float64
if mycreate && autoscalingEnabled && !isServerless {
tmp30 = 1
} else {
tmp30 = 0
}
var thisResource6 []*appautoscaling.Policy
for index := 0; index < tmp30; index++ {
    key0 := index
    _ := index
__res, err := appautoscaling.NewPolicy(ctx, fmt.Sprintf("thisResource6-%v", key0), &appautoscaling.PolicyArgs{
Name: pulumi.String(autoscalingPolicyName),
PolicyType: pulumi.String("TargetTrackingScaling"),
ResourceId: thisResource[0].ClusterIdentifier.ApplyT(func(clusterIdentifier string) (string, error) {
return fmt.Sprintf("cluster:%v", clusterIdentifier), nil
}).(pulumi.StringOutput),
ScalableDimension: pulumi.String("rds:cluster:ReadReplicaCount"),
ServiceNamespace: pulumi.String("rds"),
TargetTrackingScalingPolicyConfiguration: var tmp31 pulumi.Float64
if predefinedMetricType == "RDSReaderAverageCPUUtilization" {
tmp31 = pulumi.Float64(autoscalingTargetCpu)
} else {
tmp31 = pulumi.Float64(autoscalingTargetConnections)
}
&appautoscaling.PolicyTargetTrackingScalingPolicyConfigurationArgs{
PredefinedMetricSpecification: &appautoscaling.PolicyTargetTrackingScalingPolicyConfigurationPredefinedMetricSpecificationArgs{
PredefinedMetricType: pulumi.String(predefinedMetricType),
},
ScaleInCooldown: pulumi.Float64(autoscalingScaleInCooldown),
ScaleOutCooldown: pulumi.Float64(autoscalingScaleOutCooldown),
TargetValue: pulumi.Float64(tmp31),
},
})
if err != nil {
return err
}
thisResource6 = append(thisResource6, __res)
}
var tmp32 pulumi.String
if securityGroupUseNamePrefix {
tmp32 = nil
} else {
tmp32 = pulumi.String(name)
}
var tmp33 pulumi.String
if securityGroupUseNamePrefix {
tmp33 = pulumi.String(fmt.Sprintf("%v-", name))
} else {
tmp33 = nil
}
var tmp34 float64
if mycreate && createSecurityGroup {
tmp34 = 1
} else {
tmp34 = 0
}
var thisResource7 []*ec2.SecurityGroup
for index := 0; index < tmp34; index++ {
    key0 := index
    _ := index
__res, err := ec2.NewSecurityGroup(ctx, fmt.Sprintf("thisResource7-%v", key0), &ec2.SecurityGroupArgs{
Name: pulumi.String(tmp32),
NamePrefix: pulumi.String(tmp33),
VpcId: pulumi.String(vpcId),
Description: notImplemented("coalesce(var.security_group_description,\"Control traffic to/from RDS Aurora ${var.name}\")"),
Tags: notImplemented("merge(var.tags,var.security_group_tags,{Name=var.name})"),
})
if err != nil {
return err
}
thisResource7 = append(thisResource7, __res)
}
var thisResource8 []*ec2.SecurityGroupRule
for key0, _ := range "TODO: For expression" {
__res, err := ec2.NewSecurityGroupRule(ctx, fmt.Sprintf("thisResource8-%v", key0), &ec2.SecurityGroupRuleArgs{
Type: notImplemented("try(each.value.type,\"ingress\")"),
FromPort: notImplemented("try(each.value.from_port,local.port)"),
ToPort: notImplemented("try(each.value.to_port,local.port)"),
Protocol: ec2.ProtocolType(notImplemented("try(each.value.protocol,\"tcp\")")),
SecurityGroupId: thisResource7[0].ID(),
CidrBlocks: notImplemented("try(each.value.cidr_blocks,null)"),
Description: notImplemented("try(each.value.description,null)"),
Ipv6CidrBlocks: notImplemented("try(each.value.ipv6_cidr_blocks,null)"),
PrefixListIds: notImplemented("try(each.value.prefix_list_ids,null)"),
SourceSecurityGroupId: notImplemented("try(each.value.source_security_group_id,null)"),
})
if err != nil {
return err
}
thisResource8 = append(thisResource8, __res)
}
var thisResource11 []*cloudwatch.LogGroup
for index := 0; index < notImplemented("toset([forloginvar.enabled_cloudwatch_logs_exports:logiflocal.create&&var.create_cloudwatch_log_group&&!var.cluster_use_name_prefix])"); index++ {
    key0 := index
    val0 := index
__res, err := cloudwatch.NewLogGroup(ctx, fmt.Sprintf("thisResource11-%v", key0), &cloudwatch.LogGroupArgs{
Name: pulumi.String(fmt.Sprintf("/aws/rds/cluster/%v/%v", name, val0)),
RetentionInDays: pulumi.Float64(cloudwatchLogGroupRetentionInDays),
KmsKeyId: *pulumi.String(cloudwatchLogGroupKmsKeyId),
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
thisResource11 = append(thisResource11, __res)
}
ctx.Export("dbSubnetGroupNameOutput", mydbSubnetGroupName)
ctx.Export("clusterArn", notImplemented("try(aws_rds_cluster.this[0].arn,null)"))
ctx.Export("clusterId", notImplemented("try(aws_rds_cluster.this[0].id,null)"))
ctx.Export("clusterResourceId", notImplemented("try(aws_rds_cluster.this[0].cluster_resource_id,null)"))
ctx.Export("clusterMembersOutput", notImplemented("try(aws_rds_cluster.this[0].cluster_members,null)"))
ctx.Export("clusterEndpoint", notImplemented("try(aws_rds_cluster.this[0].endpoint,null)"))
ctx.Export("clusterReaderEndpoint", notImplemented("try(aws_rds_cluster.this[0].reader_endpoint,null)"))
ctx.Export("clusterEngineVersionActual", notImplemented("try(aws_rds_cluster.this[0].engine_version_actual,null)"))
ctx.Export("clusterDatabaseName", databaseName)
ctx.Export("clusterPort", notImplemented("try(aws_rds_cluster.this[0].port,null)"))
ctx.Export("clusterMasterPassword", notImplemented("try(aws_rds_cluster.this[0].master_password,null)"))
ctx.Export("clusterMasterUsername", notImplemented("try(aws_rds_cluster.this[0].master_username,null)"))
ctx.Export("clusterMasterUserSecret", notImplemented("try(aws_rds_cluster.this[0].master_user_secret,null)"))
ctx.Export("clusterHostedZoneId", notImplemented("try(aws_rds_cluster.this[0].hosted_zone_id,null)"))
ctx.Export("clusterInstances", thisResource2)
ctx.Export("additionalClusterEndpoints", thisResource3)
ctx.Export("clusterRoleAssociations", thisResource4)
ctx.Export("enhancedMonitoringIamRoleName", notImplemented("try(aws_iam_role.rds_enhanced_monitoring[0].name,null)"))
ctx.Export("enhancedMonitoringIamRoleArn", notImplemented("try(aws_iam_role.rds_enhanced_monitoring[0].arn,null)"))
ctx.Export("enhancedMonitoringIamRoleUniqueId", notImplemented("try(aws_iam_role.rds_enhanced_monitoring[0].unique_id,null)"))
ctx.Export("securityGroupId", notImplemented("try(aws_security_group.this[0].id,null)"))
ctx.Export("dbClusterParameterGroupArn", notImplemented("try(aws_rds_cluster_parameter_group.this[0].arn,null)"))
ctx.Export("dbClusterParameterGroupId", notImplemented("try(aws_rds_cluster_parameter_group.this[0].id,null)"))
ctx.Export("dbParameterGroupArn", notImplemented("try(aws_db_parameter_group.this[0].arn,null)"))
ctx.Export("dbParameterGroupId", notImplemented("try(aws_db_parameter_group.this[0].id,null)"))
ctx.Export("dbClusterCloudwatchLogGroups", thisResource11)
return nil
})
}
: 987:43: expected operand, found 'var' (and 10 more errors)
justinvp commented 1 year ago

Error converting https://github.com/terraform-aws-modules/terraform-aws-acm to go:

pulumi convert --from terraform --language go --out /var/folders/xg/z6dhmklj23540z44cm7sgkcr0000gn/T/converter-output129342355
warning: Plugin converters are currently experimental
error: could not generate output program: invalid Go source code:

package main

import (

"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/acm"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/route53"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func notImplemented(message string) pulumi.AnyOutput {
    panic(message)
}

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
// Whether to create ACM certificate
createCertificate := true;
if param := cfg.GetBool("createCertificate"); param {
createCertificate = param
}
// Whether to create only Route53 records (e.g. using separate AWS provider)
createRoute53RecordsOnly := false;
if param := cfg.GetBool("createRoute53RecordsOnly"); param {
createRoute53RecordsOnly = param
}
// Whether to validate certificate by creating Route53 record
validateCertificate := true;
if param := cfg.GetBool("validateCertificate"); param {
validateCertificate = param
}
// Whether to allow overwrite of Route53 records
validationAllowOverwriteRecords := true;
if param := cfg.GetBool("validationAllowOverwriteRecords"); param {
validationAllowOverwriteRecords = param
}
// Whether to wait for the validation to complete
waitForValidation := true;
if param := cfg.GetBool("waitForValidation"); param {
waitForValidation = param
}
// Define maximum timeout to wait for the validation to complete
validationTimeout := nil;
if param := cfg.GetBool("validationTimeout"); param != nil {
validationTimeout = param
}
// Specifies whether certificate details should be added to a certificate transparency log
certificateTransparencyLoggingPreference := true;
if param := cfg.GetBool("certificateTransparencyLoggingPreference"); param {
certificateTransparencyLoggingPreference = param
}
// A domain name for which the certificate should be issued
domainName := "";
if param := cfg.Get("domainName"); param != ""{
domainName = param
}
// A list of domains that should be SANs in the issued certificate
subjectAlternativeNames := []interface{}{
};
if param := cfg.GetBool("subjectAlternativeNames"); param != nil {
subjectAlternativeNames = param
}
// Which method to use for validation. DNS or EMAIL are valid, NONE can be used for certificates that were imported into ACM and then into Terraform.
validationMethod := "DNS";
if param := cfg.Get("validationMethod"); param != ""{
validationMethod = param
}
// The domain name that you want ACM to use to send you validation emails. This domain name is the suffix of the email addresses that you want ACM to use.
validationOption := nil;
if param := cfg.GetBool("validationOption"); param != nil {
validationOption = param
}
// When validation is set to DNS, define whether to create the DNS records internally via Route53 or externally using any DNS provider
createRoute53Records := true;
if param := cfg.GetBool("createRoute53Records"); param {
createRoute53Records = param
}
// When validation is set to DNS and the DNS validation records are set externally, provide the fqdns for the validation
validationRecordFqdns := []interface{}{
};
if param := cfg.GetBool("validationRecordFqdns"); param != nil {
validationRecordFqdns = param
}
// The ID of the hosted zone to contain this record. Required when validating via Route53
zoneId := "";
if param := cfg.Get("zoneId"); param != ""{
zoneId = param
}
// A mapping of tags to assign to the resource
tags := nil;
if param := cfg.GetBool("tags"); param != nil {
tags = param
}
// The TTL of DNS recursive resolvers to cache information about this record.
dnsTtl := float64(60);
if param := cfg.GetFloat64("dnsTtl"); param != 0 {
dnsTtl = param
}
// A list of domain_validation_options created by the ACM certificate to create required Route53 records from it (used when create_route53_records_only is set to true)
acmCertificateDomainValidationOptions := nil;
if param := cfg.GetBool("acmCertificateDomainValidationOptions"); param != nil {
acmCertificateDomainValidationOptions = param
}
// List of distinct domains and SANs (used when create_route53_records_only is set to true)
distinctDomainNames := []interface{}{
};
if param := cfg.GetBool("distinctDomainNames"); param != nil {
distinctDomainNames = param
}
// Specifies the algorithm of the public and private key pair that your Amazon issued certificate uses to encrypt data
keyAlgorithm := nil;
if param := cfg.GetBool("keyAlgorithm"); param != nil {
keyAlgorithm = param
}
// Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!
putinKhuylo := true;
if param := cfg.GetBool("putinKhuylo"); param {
putinKhuylo = param
}
mycreateCertificate := createCertificate && putinKhuylo;
mycreateRoute53RecordsOnly := createRoute53RecordsOnly && putinKhuylo;
mydistinctDomainNames := notImplemented("coalescelist(var.distinct_domain_names,distinct(\n[forsinconcat([var.domain_name],var.subject_alternative_names):replace(s,\"*.\",\"\")]\n))");
var tmp0 interface{}
if mycreateCertificate || mycreateRoute53RecordsOnly {
tmp0 = notImplemented("distinct(\n[fork,vintry(aws_acm_certificate.this[0].domain_validation_options,var.acm_certificate_domain_validation_options):merge(\ntomap(v),{domain_name=replace(v.domain_name,\"*.\",\"\")}\n)]\n)")
} else {
tmp0 = []interface{}{
}
}
validationDomains := tmp0;
var tmp1 float64
if mycreateCertificate {
tmp1 = 1
} else {
tmp1 = 0
}
var this []*acm.Certificate
for index := 0; index < tmp1; index++ {
    key0 := index
    _ := index
__res, err := acm.NewCertificate(ctx, fmt.Sprintf("this-%v", key0), &acm.CertificateArgs{
ValidationOptions: "TODO: For expression",
DomainName: pulumi.String(domainName),
SubjectAlternativeNames: subjectAlternativeNames,
ValidationMethod: pulumi.String(validationMethod),
KeyAlgorithm: *pulumi.String(keyAlgorithm),
Options: var tmp2 pulumi.String
if certificateTransparencyLoggingPreference {
tmp2 = pulumi.String("ENABLED")
} else {
tmp2 = pulumi.String("DISABLED")
}
&acm.CertificateOptionsArgs{
CertificateTransparencyLoggingPreference: pulumi.String(tmp2),
},
Tags: pulumi.Pulumi.StringMap(tags),
})
if err != nil {
return err
}
this = append(this, __res)
}
var tmp3 float64
if (mycreateCertificate || mycreateRoute53RecordsOnly) && validationMethod == "DNS" && createRoute53Records && (validateCertificate || mycreateRoute53RecordsOnly) {
tmp3 = len(mydistinctDomainNames)
} else {
tmp3 = 0
}
var validation []*route53.Record
for index := 0; index < tmp3; index++ {
    key0 := index
    _ := index
__res, err := route53.NewRecord(ctx, fmt.Sprintf("validation-%v", key0), &route53.RecordArgs{
ZoneId: pulumi.String(zoneId),
Name: notImplemented("element(local.validation_domains,count.index)").Resource_record_name,
Type: route53.RecordType(notImplemented("element(local.validation_domains,count.index)").Resource_record_type),
Ttl: pulumi.Float64(dnsTtl),
Records: pulumi.StringArray{
notImplemented("element(local.validation_domains,count.index)").Resource_record_value,
},
AllowOverwrite: pulumi.Bool(validationAllowOverwriteRecords),
})
if err != nil {
return err
}
validation = append(validation, __res)
}
var tmp4 float64
if mycreateCertificate && validationMethod != "NONE" && validateCertificate && waitForValidation {
tmp4 = 1
} else {
tmp4 = 0
}
var thisResource []*acm.CertificateValidation
for index := 0; index < tmp4; index++ {
    key0 := index
    _ := index
__res, err := acm.NewCertificateValidation(ctx, fmt.Sprintf("thisResource-%v", key0), &acm.CertificateValidationArgs{
CertificateArn: this[0].Arn,
ValidationRecordFqdns: notImplemented("flatten([aws_route53_record.validation[*].fqdn,var.validation_record_fqdns])"),
})
if err != nil {
return err
}
thisResource = append(thisResource, __res)
}
ctx.Export("acmCertificateArn", notImplemented("try(aws_acm_certificate_validation.this[0].certificate_arn,aws_acm_certificate.this[0].arn,\"\")"))
ctx.Export("acmCertificateDomainValidationOptionsOutput", notImplemented("flatten(aws_acm_certificate.this[*].domain_validation_options)"))
ctx.Export("acmCertificateStatus", notImplemented("try(aws_acm_certificate.this[0].status,\"\")"))
ctx.Export("acmCertificateValidationEmails", notImplemented("flatten(aws_acm_certificate.this[*].validation_emails)"))
var splat0 pulumi.StringArray
for _, val0 := range validation {
splat0 = append(splat0, val0.Fqdn)
}
ctx.Export("validationRoute53RecordFqdns", splat0)
ctx.Export("distinctDomainNamesOutput", mydistinctDomainNames)
ctx.Export("validationDomainsOutput", validationDomains)
return nil
})
}
: 148:10: expected operand, found 'var' (and 5 more errors)
justinvp commented 1 year ago

Try to format, if we can't format it, just continue on with unformatted code.

Zaid-Ajaj commented 1 year ago

Tracked and simplified this program down to this PCL:

config "vpcId" "string" {
  default     = null
  description = "VPC id where the load balancer and other resources will be deployed."
}

config "loadBalancerType" "string" {
  default     = "application"
  description = "The type of load balancer to create. Possible values are application or network."
}

config "securityGroups" "list(string)" {
  default     = []
  description = "The security groups to attach to the load balancer. e.g. [\"sg-edcd9784\",\"sg-edcd9785\"]"
}

createSecurityGroup = true

resource "sg" "aws:ec2/securityGroup:SecurityGroup" {
  options {
    range = createSecurityGroup ? 1 : 0
  }
  vpcId = vpcId
}

computedSecurityGroups = createSecurityGroup && loadBalancerType == "application" ? invoke("std:index:concat", {
    input = [[sg[0].id], securityGroups]
  }).result : securityGroups

Where the final variable declaration fails to generate valid go code:

var tmp1 pulumi.AnyArray
if createSecurityGroup && loadBalancerType == "application" {
tmp1 = std.Concat(ctx, &std.ConcatArgs{
Input: []interface{}{
pulumi.StringArray{
sg[0].ID(),
},
securityGroups,
},
}, nil).ApplyT(func(invoke std.ConcatResult) ([]interface{}, error) {
return invoke.Result, nil
}).(pulumi.[]interface{}Output)
} else {
tmp1 = securityGroups
}

This has two issues:

justinvp commented 1 year ago

Fixed by https://github.com/pulumi/pulumi/pull/13053