echoing-park-18112
01/22/2025, 8:19 AMconst
export const serviceAccountEmail = serviceAccount.email
export const workloadIdentityPoolId = workloadIdentityPool.workloadIdentityPoolId
export const workloadIdentityProviderId = workloadIdentityProvider.workloadIdentityPoolProviderId
and in the index.ts
I have this
import { serviceAccountEmail, workloadIdentityPoolId, workloadIdentityProviderId } from './resources/iam/gh-federated'
/**
* GitHub Workflow Identity Provider information
* check the resources/iam/gh-federated.ts for the full code
*/
console.log('Service Account Email:', serviceAccountEmail)
console.log('Workload Identity Pool ID:', workloadIdentityPoolId)
console.log('Workload Identity Provider ID:', workloadIdentityProviderId)
All the resources are created correctly but in the console I always have this
Service Account Email: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
Workload Identity Pool ID: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
Workload Identity Provider ID: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
how do I obtain the value that I need?kind-caravan-54693
01/22/2025, 8:49 AMOutputs are a unique and complex type in Pulumi which behave very much like promises.We cannot check the value of a promise using console.log. https://www.pulumi.com/docs/iac/concepts/inputs-outputs/
echoing-park-18112
01/22/2025, 8:55 AMexport const serviceAccountEmail = serviceAccount.email.apply(email => email)
kind-caravan-54693
01/22/2025, 9:18 AMso I need to change it into something like this?There should be no need to use apply. Example:export const serviceAccountEmail = serviceAccount.email.apply(email => email)
const vpcCidr = config.require(KEY_NAME.VPC_CIDR);
export const vpc = new awsNative.ec2.Vpc(strVpc, vpcArgs);
const albSgArgs: awsNative.ec2.SecurityGroupArgs = {
vpcId: vpc.id,
groupDescription: 'Allow HTTP and HTTPS traffic',
securityGroupIngress: [
{ ipProtocol: "tcp", fromPort: 80, toPort: 80, cidrIp: vpcCidr, },
],
tags: createAwsNativeTags({ Name: strAlbSG })
};
echoing-park-18112
01/22/2025, 9:22 AMconst serviceAccount = new gcp.serviceaccount.Account('github-actions-sa', {
accountId: 'github-actions-sa',
displayName: 'GitHub Actions Service Account',
description: 'A service account for use in a GitHub Actions workflow',
})
export const serviceAccountEmail = serviceAccount.email
Then I import it and console.log it in index.ts
echoing-park-18112
01/22/2025, 9:23 AMconst workloadIdentityPool = new gcp.iam.WorkloadIdentityPool('github-actions-pool', {
workloadIdentityPoolId: 'github-actions-pool',
displayName: 'GitHub Workload Identity Pool',
description: 'GitHub Workload Identity Pool',
})
// Create a Workload Identity Provider
const workloadIdentityProvider = new gcp.iam.WorkloadIdentityPoolProvider('github-actions-provider', {
workloadIdentityPoolId: workloadIdentityPool.workloadIdentityPoolId,
workloadIdentityPoolProviderId: 'github-actions-provider',
...
is just the console.log
in the index.ts
kind-caravan-54693
01/22/2025, 9:29 AMechoing-park-18112
01/22/2025, 9:30 AMapply
makes sense for this case?quick-house-41860
01/22/2025, 9:31 AMserviceAccountEmail.apply(email => console.log(email))
The logging needs to be done within the apply, that callback is executed once the value is resolvedquick-house-41860
01/22/2025, 9:32 AMserviceAccount.email.apply(email => email)
would essentially be a noop, because apply returns an Output
againechoing-park-18112
01/22/2025, 9:35 AMService Account Email: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
Workload Identity Pool ID: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
Workload Identity Provider ID: OutputImpl {
__pulumiOutput: true,
resources: [Function (anonymous)],
allResources: [Function (anonymous)],
isKnown: Promise { <pending> },
isSecret: Promise { <pending> },
promise: [Function (anonymous)],
toString: [Function (anonymous)],
toJSON: [Function (anonymous)]
}
github-actions-pool
github-actions-sa@my-project.iam.gserviceaccount.com
github-actions-provider
in the index.ts
shall I leave the console.log or should I export the main const
and in index.ts
doing this
console.log('Service Account Email:', serviceAccount.email.apply((email) => console.log(email)))
?quick-house-41860
01/22/2025, 9:37 AMechoing-park-18112
01/22/2025, 9:38 AMresources/iam/gh-federated.ts
I have the main code with the export of the above const, in index.ts
I import them and use console.log('const-desc', const)
quick-house-41860
01/22/2025, 9:39 AMyourConst.apply(c => console.log('desc', c))
echoing-park-18112
01/22/2025, 9:41 AMindex.ts
works
serviceAccount.email.apply((email) => console.log('Service Account Email:', email))
workloadIdentityPool.workloadIdentityPoolId.apply((id) =>
console.log('Workload Identity Pool ID:', id)
)
workloadIdentityProvider.workloadIdentityPoolProviderId.apply((id) =>
console.log('Workload Identity Provider ID:', id)
)
and in the other file, I have export const serviceAccount = new gcp.serviceaccount.Account('github-actions-sa', {..
etcquick-house-41860
01/22/2025, 9:42 AMechoing-park-18112
01/22/2025, 9:44 AMresources/iam/gh-federated.ts
inside a function and then call it inside index.ts
🤔 what would be the best practice here?
I see that this is working only because I import those const
in the main file else it wouldn't run at allquick-house-41860
01/22/2025, 9:47 AMconst ghFederation = new GithubFederationSetup("name", {...});
ghFederation.email.apply(email => console.log(email));
echoing-park-18112
01/22/2025, 9:48 AM