```package aks import ( "fmt" "<http://githu...
# golang
Copy code
package aks

import (


type Aks struct {
  resourceId pulumi.StringOutput
  name       pulumi.StringOutput

type AksArgs struct {
  EnableRBAC        pulumi.BoolInput
  ResourceName      pulumi.StringInput
  KubernetesVersion pulumi.StringInput
  NodeResourceGroup pulumi.StringInput
  ResourceGroup     pulumi.StringInput
  NodeCount         pulumi.IntInput
  Location          pulumi.StringInput

func CreateAks(ctx *pulumi.Context, name string, args *AksArgs, opts ...pulumi.ResourceOption) (*Aks, error) {
  aks := &Aks{}

  err := ctx.RegisterComponentResource("resource:index:Aks", name, aks, opts...)
  if err != nil {
    return nil, err

  rgs, err := core.NewResourceGroup(ctx, "resourceGroups", &core.ResourceGroupArgs{
    Name:     args.ResourceGroup,
    Location: args.Location,
  }, pulumi.Parent(aks))

  if err != nil {
    return nil, fmt.Errorf("error creating resource group: %v", err)

  k8s, err := containerservice.NewManagedCluster(ctx, "akss", &containerservice.ManagedClusterArgs{
    Location: rgs.Location,
    AgentPoolProfiles: containerservice.ManagedClusterAgentPoolProfileArray{
        Count:              args.NodeCount,
        EnableAutoScaling:  pulumi.Bool(false),
        EnableNodePublicIP: pulumi.Bool(true),
        Mode:               pulumi.String("System"),
        Name:               pulumi.String("default"),
        OsType:             pulumi.String("Linux"),
        Type:               pulumi.String("VirtualMachineScaleSets"),
        VmSize:             pulumi.String("Standard_B2s"),
    DnsPrefix:         pulumi.String("akss"),
    EnableRBAC:        args.EnableRBAC,
    Identity:          &containerservice.ManagedClusterIdentityArgs{Type: containerservice.ResourceIdentityTypeSystemAssigned},
    KubernetesVersion: args.KubernetesVersion,
    NodeResourceGroup: args.NodeResourceGroup,
    ResourceGroupName: rgs.Name,
    ResourceName:      args.ResourceName,
    Sku: &containerservice.ManagedClusterSKUArgs{
      Name: pulumi.String("Basic"),
      Tier: pulumi.String("Free"),
  }, pulumi.Parent(rgs))

  if err != nil {
    return nil, fmt.Errorf("error creating cluster: %v", err)

  ctx.RegisterResourceOutputs(aks, pulumi.Map{
    "resourceId": k8s.ID(),
    "name":       k8s.Name,
  return aks, nil
you need to
them from your pulumi main function that uses your
you have some sample somewhere?
@quiet-laptop-13439 if you want to use this output as input for another function you also should do this in the main function right?
no, you create a field in your Aks struct and access that field directly
e.g. aks, err := NewAks(...)
somethingElseArgs:= { AksId: aks.ID() }
if you want k8s.Name there, just create Name in Aks struct, and at the end of your NewAks assign
aks.Name = k8s.Name.ToStringOutput()
, or something similar
Also when i have two different pacackes? aks.go and acr.go are in different packages
In the main.go file i reference those functions
So if i want to use output between functions i can do this directly?
cant make too many assumptions about your package structure, but if you can pass outputs via args after assignment, similar to terraform
Yeah terraform is referencing outputs through main
@billowy-army-68599 the complete code is at https://github.com/dkooll/pulumi-go-webapp
Will have a look at your examples
my main question would be how to use for example something like a aks cluster ID as input in the ACR package with the current package structure using different functions and packages
resource components should be ok in this sample right?
@billowy-army-68599 you have some time to look? 😀
If I do it won't be for a couple days I'm afraid
@quiet-laptop-13439, @billowy-army-68599 i got a working output now using
Copy code
aksnames := k8s.Name.ApplyT(func(aksname string) string {
    return aksname

  aks.AksNames = aksnames

  if err := ctx.RegisterResourceOutputs(aks, pulumi.Map{
    "aksnames": aksnames,
  }); err != nil {
    return nil, err

  ctx.Export("AksNames", aks.AksNames)
  return aks, nil
you have any idea how i get the id instead of the name
you dont need that applyt, it does nothing
ahk.. thanks.. according to the docs Id should be available as output
for id just do the same assignment
as for the name, just type is different
it give me a
k8s.Id undefined (type *containerservice.ManagedCluster has no field or method Id)
Copy code
aksnames := k8s.Id.ApplyT(func(aksname string) string {
    return aksname
am i missing something
im not following why did you do that
first, as i said, you dont need that applyt
id is k8s.ID()
can you provide a more complete sample to make this a output using component resources, cause this aint helping much
I'm on a phone
do you intend aksnames to be an array?
Copy code
aks.AksNames = k8s.Name
Copy code
aks.ResourceId := k8s.ID() // make sure Aks struct field is ResourceId
remove ctx.Export from the module, do it in main
Copy code
ctx.Export("k8s_resource_id", aks.ResourceId)
hmm thanks.. only getting a
expected identifier on left side of :=
on this one aks.ResourceId := k8s.ID()
for example
aks.ResourceState := k8s.State()
works, but
aks.ResourceId := k8s.ID()
gives me a
expected identifier on left side of :=
@quiet-laptop-13439 if i remove the semicolon i get a
cannot use k8s.ID() (value of type pulumi.IDOutput) as pulumi.StringOutput value in assignment
so this one works
aks.ResourceId = k8s.ID().ToStringOutput()
so this is working.. now how to pass this output which is in the aks package as input to a resource in the acr package?
do i have to pass this in my main function?