Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use 'dataBaseServer.ID()' (type IDOutput) as the type IntInputType #534

Closed
ayumakesit opened this issue Nov 8, 2023 · 5 comments
Closed
Assignees
Labels
area/docs Improvements or additions to documentation awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue

Comments

@ayumakesit
Copy link

ayumakesit commented Nov 8, 2023

What happened?

Following the example to create a firewall I’m trying to use the ID of the created droplet.
The example: https://www.pulumi.com/registry/packages/digitalocean/api-docs/firewall/

I get the following error:

Cannot use 'dataBaseServer.ID()' (type IDOutput) as the type IntInputType does not implement 'IntInput' as some methods are missing:ToIntOutput() IntOutputToIntOutputWithContext(ctx context.Context) IntOutputToIntPtrOutput() IntPtrOutput…

Example

dataBaseServer, err := do.NewDroplet(ctx, name, &do.DropletArgs{
	Size:    pulumi.String("s-1vcpu-2gb"),
	Image:   pulumi.String("ubuntu-22-04-x64"),
	Region:  pulumi.String(region),
	VpcUuid: vpc.ID(),
})

if err != nil {
	return err
}

_, err = do.NewFirewall(ctx, "databaseFirewall", &do.FirewallArgs{
	DropletIds: pulumi.IntArray{
		dataBaseServer.ID(),
	},
	InboundRules: do.FirewallInboundRuleArray{},
	OutboundRules: do.FirewallOutboundRuleArray{},
})

Output of pulumi about

CLI
Version 3.92.0
Go Version go1.21.3
Go Compiler gc

Plugins
NAME VERSION
digitalocean 4.23.0
go unknown

Host
OS darwin
Version 14.1
Arch arm64

Dependencies:
NAME VERSION
github.com/pulumi/pulumi-digitalocean/sdk/v4 4.23.0
github.com/pulumi/pulumi/sdk/v3 3.92.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@ayumakesit ayumakesit added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 8, 2023
@mikhailshilkov
Copy link
Member

Hi @ayumakesit

This is because resource IDs are strings in Pulumi, while DropletIds expects integers. Assuming dataBaseServer.ID() is in fact an integer, you should be able to convert it with something like

_, err = do.NewFirewall(ctx, "databaseFirewall", &do.FirewallArgs{
	DropletIds: pulumi.IntArray{
		dataBaseServer.ID().ToStringOutput().ApplyT(func(id string) int {
			v, _ := strconv.Atoi(id)
			return v
		}).(pulumi.IntOutput),
	},
	InboundRules: do.FirewallInboundRuleArray{},
	OutboundRules: do.FirewallOutboundRuleArray{},
})

A similar issue for TypeScript: #81

Let me know if this helps.

@mikhailshilkov mikhailshilkov added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Nov 10, 2023
@ayumakesit
Copy link
Author

Hi @mikhailshilkov,
thank you for the response :)

I already converted it:

_, err = do.NewFirewall(ctx, "databaseFirewall", &do.FirewallArgs{
	DropletIds: pulumi.IntArray{
		dataBaseServer.ID().ApplyT(strconv.Atoi).(pulumi.IntOutput),
	},
	InboundRules: do.FirewallInboundRuleArray{
		&do.FirewallInboundRuleArgs{
			Protocol:  pulumi.String("tcp"),
			PortRange: pulumi.String("22"),
		},
	},
	OutboundRules: do.FirewallOutboundRuleArray{},
})

For newbies like me, it would be very helpful if the documentation could show the right way ;)

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Nov 10, 2023
@mikhailshilkov
Copy link
Member

Great to hear you are unblocked! I'll leave the issue open to track fixing the example.

@mikhailshilkov mikhailshilkov added area/docs Improvements or additions to documentation and removed needs-triage Needs attention from the triage team labels Nov 10, 2023
@mikhailshilkov
Copy link
Member

Upstream pu/pu issue: pulumi/pulumi#9841

@mikhailshilkov mikhailshilkov added the awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). label Nov 13, 2023
@mjeffryes mjeffryes added the resolution/duplicate This issue is a duplicate of another issue label Sep 26, 2024
@mjeffryes
Copy link
Member

Tracked by #600

@mjeffryes mjeffryes self-assigned this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/bug Some behavior is incorrect or out of spec resolution/duplicate This issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants