hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 455 forks source link

Azurerm Provider: Allow Accessing current user object ID #3761

Open thekevinbrown opened 2 weeks ago

thekevinbrown commented 2 weeks ago

Description

I’m trying to create a certificate in Azure key vault with CDKTF. To do that, I need a key vault policy applied that allows the CDKTF user to do this action. The code I’ve got to do that currently looks like this:

// The deploying user (us right now in CDKTF context) need to be able to manage certificates
const deployerAccessForCertificates = new KeyVaultAccessPolicyA(
    construct,
    `deploy-key-vault-access`,
    {
        keyVaultId: vault.id,
        objectId: process.env.AZURE_APP_REGISTRATION_OBJECT_ID ?? '',
        tenantId: vault.tenantId,
        certificatePermissions: ['Create', 'Get', 'List', 'Delete'],
    }
);

This is really annoying though, because I’m already authenticating successfully and I’d like to have one less constant to pull from the Azure console. I see that this is supported in the azurerm provider now, how do I access it from CDK code? E.g. I’d like the objectId value in the above snippet to be able to grab the current user’s objectId.

References

No response

Help Wanted

Community Note