cold-orange-37453
07/27/2022, 11:00 AMResources
require a slice of string ([]string) , I wan to pass some values here that I am creating in the pulumi code as well. Is there any way to do this ? I can just put the string value there since resource arn format is pre determined, but is there any better way ?billowy-army-68599
fancy-spoon-7206
07/27/2022, 6:16 PMcold-orange-37453
07/28/2022, 7:57 AMcodepipelineIAMPolicyDocument, err := piam.GetPolicyDocument(ctx, &piam.GetPolicyDocumentArgs{
Statements: []piam.GetPolicyDocumentStatement{
{
Sid: util.StringPtr("ECSLambdaInvokePermissions"),
Effect: &effectAllow,
Actions: []string{"lambda:InvokeFunction"},
Resources: []string{
config.TaskDefLambdaArn,
config.DeployLambdaArn,
},
},
},
}, pulumi.Parent(component))
For example here , Resources block requires a string of slice
I am getting these values via the Getter method analogous to data block in terraform
Example of one getter func
gitCommitStatusLambda, err := plambda.GetFunction(ctx, "git-commit-status-lambda", pulumi.ID("git-commit-status"), nil)
if err != nil {
log.WithError(err).Error("failed to git commit status lambda")
return err
}
z.GitCommitStatusLambda = gitCommitStatusLambda.ID().ToStringOutput()
this returns to me a pulumi.StringOutput , I want to be able to pass this value directly to the Resources block above , but it requires strings
@fancy-spoon-7206
I guess in pulumi Getters can not depend on outputs , correct me if I am wrongfancy-spoon-7206
07/28/2022, 1:28 PMcold-orange-37453
07/28/2022, 1:33 PMfancy-spoon-7206
07/28/2022, 2:05 PMapply
function the value is a string so you can apply
where ever you need the value to be string.cold-orange-37453
07/29/2022, 4:50 AMwg.Add(1)
gitCommitStatusLambda, err := plambda.GetFunction(ctx, "git-commit-status-lambda", pulumi.ID("git-commit-status"), nil)
if err != nil {
log.WithError(err).Error("failed to git commit status lambda")
return err
}
gitCommitStatusLambda.ID().ToStringOutput().ApplyT(func (v string) {
z.GitCommitStatusLambda = v
})
Working for me now, IMO it would have been better if all the Getter functions could take args of the pulumi.Output type as wellbillowy-army-68599
cold-orange-37453
07/29/2022, 5:09 AM