Hey, is there a way to get the default subnet from...
# aws
c
Hey, is there a way to get the default subnet from the default Vpc and give it to a StateMachine definition? (with node)
b
How is your state machine defined? Not familiar with that specifically
c
Something like this :
Copy code
const test = new aws.sfn.StateMachine('test', {
  roleArn: sfnRole.arn,
  definition: pulumi
    .all([
      fgTaskDefinition.taskDefinition.arn,
      fgTaskDefinitionCluster.cluster.arn
    ])
    .apply(([fgTaskDefinitionArn, fgClusterDefinitionArn]) =>
      JSON.stringify({
        Comment: 'Test',
        StartAt: 'Test',
        States: {
          Test: {
            Type: 'Task',
            Resource: 'arn:aws:states:::<ecs:runTask.waitForTaskToken>',
            Parameters: {
              LaunchType: 'FARGATE',
              Cluster: fgClusterDefinitionArn,
              TaskDefinition: fgTaskDefinitionArn,
              Overrides: {
                ContainerOverrides: [
                  {
                    Name: 'test',
                    Environment: [
                      {
                        Name: 'TASK_TOKEN_ENV_VARIABLE',
                        'Value.$': '$$.Task.Token'
                      }
                    ]
                  }
                ]
              },
              NetworkConfiguration: {
                AwsvpcConfiguration: {
                  Subnets: [""], // Dynamically take the default subnet 
                  AssignPublicIp: 'ENABLED'
                }
              }
            },
            End: true
          }
        }
      })
    )
})
b
awsx will get you the default VPC:
Copy code
import * as awsx from "@pulumi/awsx";

const vpc = awsx.ec2.Vpc.getDefault();
c
Yes, but i need the subnet inside the Vpc.
Copy code
awsx.ec2.Vpc.getDefault()
return the Vpc. If i try to get the subnet with
vpc.publicSubnetIds
or
vpc.getSubnetsIds()
return is a promise with an array of pulumi.output and it can't be used inside pulumi.all
b
why can't it be used inside
pulumi.all
? you should be able to use
apply()
on it as normal
c
Oh yes. You right. I have an error when i do it but I just realized that it is not related. I have an error cause i use to many element (with different type) into pulumi.all and its limited to 8 elements.
b
i'm checking that there's a limit, I've not heard of one
Copy code
all<T1,T2,T3,T4,T5,T6,T7,T8>
b
yep, i'm trying to determine why that is
f
@colossal-camera-57941 Could you provide the code you’re using that’s hitting the problem w/
all
? In the above, I only saw usage with the array-form with 2 elements in the array.
c
Yes sure:
Copy code
const testSfn = new aws.sfn.StateMachine('testSfn', {
  roleArn: sfnRole.arn,
  definition: pulumi
    .all([
      awsx.ec2.Vpc.getDefault().publicSubnetIds,
      bucket1.bucket,
      bucket2.bucket,
      queue1.name,
      fgTaskDefinition.taskDefinition.arn,
      fgTaskDefinitionCluster.cluster.arn,
      lambda1.arn,
      lambda2Fun.arn,
      lambda3Fun.arn,
      lambda4Fun.arn,
      lambda5Fun.arn,
      lambda6Fun.arn
    ])
    .apply(
      ([
        subnets,
        bucket1Name,
        bucket2BucketName,
        queue1Name,
        fgTaskDefinitionArn,
        fgClusterDefinitionArn,
        lambda1Arn,
        lambda2Arn,
        lambda3Arn,
        lambda4Arn,
        lambda5Arn,
        lambda6Arn
      ]) =>
        JSON.stringify({
          Comment: 'Test',
          StartAt: 'lambda1',
          States: {
            lambda1: {
              Type: 'Task',
              Resource: lambda1Arn,
              Next: 'lambda2'
            },
            lambda2: {
              Type: 'Task',
              Resource: lambda2Arn,
              Next: 'lambda3'
            },
            lambda3: {
              Type: 'Task',
              Resource: lambda3Arn,
              Next: 'lambda4'
            },
            lambda4: {
              Type: 'Task',
              Resource: lambda4Arn,
              Next: 'lambda5'
            },
            lambda5: {
              Type: 'Task',
              Resource: lambda5Arn,
              Next: 'lambda6'
            },
            lambda6: {
              Type: 'Task',
              Resource: lambda6Arn,
              Next: 'fgTask'
            },
            fgTask: {
              Type: 'Task',
              Resource: 'arn:aws:states:::ecs:runTask.waitForTaskToken',
              Parameters: {
                LaunchType: 'FARGATE',
                Cluster: fgClusterDefinitionArn,
                TaskDefinition: fgTaskDefinitionArn,
                Overrides: {
                  ContainerOverrides: [
                    {
                      Name: 'fgTask',
                      Environment: [
                        {
                          Name: 'TASK_TOKEN_ENV_VARIABLE',
                          'Value.$': '$$.Task.Token'
                        },
                         {
                          Name: 'BUCKET1',
                          Value: bucket1
                        },
                        {
                          Name: 'BUCKET2',
                          Value: bucket2
                        },
                        { Name: 'QUEUE1', Value: queue1 },
                      ]
                    }
                  ]
                },
                NetworkConfiguration: {
                  AwsvpcConfiguration: {
                    Subnets: [subnets],
                    AssignPublicIp: 'ENABLED'
                  }
                }
              },
              End: true
            }
          }
        })
    )
})
This is the case with the problem @faint-table-42725
f
@colossal-camera-57941 Interesting. What’s the error you’re getting? In a small repro I just tried, I couldn’t get a compile-time error by using an array of outputs passed to
all
c
@faint-table-42725
Copy code
The last overload gave the following error.
    Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
      Type 'Output<string>' is not assignable to type 'OutputInstance<Output<string>[]>'.
        Types of property 'apply' are incompatible.
          Type '{ <U>(func: (t: string) => Promise<U>): Output<U>; <U>(func: (t: string) => OutputInstance<U>): Output<U>; <U>(func: (t: string) => U): Output<U>; }' is not assignable to type '{ <U>(func: (t: Output<string>[]) => Promise<U>): Output<U>; <U>(func: (t: Output<string>[]) => OutputInstance<U>): Output<U>; <U>(func: (t: Output<string>[]) => U): Output<U>; }'.
            Types of parameters 'func' and 'func' are incompatible.
              Types of parameters 't' and 't' are incompatible.
                Type 'string' is not assignable to type 'Output<string>[]'.
                  Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                    Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                      Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                        Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                          Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                            Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                              Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                                Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                                  Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
                                    Type 'Output<string>' is not assignable to type 'Input<Output<string>[]> | undefined'.
Did you try to define 8 pulumi.output and 1 pulumi.output[] into the
all
? like that:
Copy code
definition: pulumi
    .all([
      awsx.ec2.Vpc.getDefault().publicSubnetIds, // pulumi.Output<string>[]
      bucket1.bucket, // pulumi.Output<string>
      bucket2.bucket, // pulumi.Output<string>
      queue1.name, // pulumi.Output<string>
      fgTaskDefinition.taskDefinition.arn, // pulumi.Output<string>
      fgTaskDefinitionCluster.cluster.arn, // pulumi.Output<string>
      lambda1.arn, // pulumi.Output<string>
      lambda2Fun.arn, // pulumi.Output<string>
      lambda3Fun.arn, // pulumi.Output<string>
      lambda4Fun.arn, // pulumi.Output<string>
      lambda5Fun.arn, // pulumi.Output<string>
      lambda6Fun.arn // pulumi.Output<string>
    ])
    .apply(
      ([
        subnets,
        bucket1Name,
        bucket2BucketName,
        queue1Name,
        fgTaskDefinitionArn,
        fgClusterDefinitionArn,
        lambda1Arn,
        lambda2Arn,
        lambda3Arn,
        lambda4Arn,
        lambda5Arn,
        lambda6Arn
      ])