com.pulumi.azure.keyvault.ManagedStorageAccount Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure Show documentation
Show all versions of azure Show documentation
A Pulumi package for creating and managing Microsoft Azure cloud resources, based on the Terraform azurerm provider. We recommend using the [Azure Native provider](https://github.com/pulumi/pulumi-azure-native) to provision Azure infrastructure. Azure Native provides complete coverage of Azure resources and same-day access to new resources and resource updates.
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package com.pulumi.azure.keyvault;
import com.pulumi.azure.Utilities;
import com.pulumi.azure.keyvault.ManagedStorageAccountArgs;
import com.pulumi.azure.keyvault.inputs.ManagedStorageAccountState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
/**
* Manages a Key Vault Managed Storage Account.
*
* ## Example Usage
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.azure.core.CoreFunctions;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.storage.Account;
* import com.pulumi.azure.storage.AccountArgs;
* import com.pulumi.azure.keyvault.KeyVault;
* import com.pulumi.azure.keyvault.KeyVaultArgs;
* import com.pulumi.azure.keyvault.inputs.KeyVaultAccessPolicyArgs;
* import com.pulumi.azure.keyvault.ManagedStorageAccount;
* import com.pulumi.azure.keyvault.ManagedStorageAccountArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
*
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
*
* public static void stack(Context ctx) {
* final var current = CoreFunctions.getClientConfig();
*
* var example = new ResourceGroup("example", ResourceGroupArgs.builder()
* .name("example-resources")
* .location("West Europe")
* .build());
*
* var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
* .name("storageaccountname")
* .resourceGroupName(example.name())
* .location(example.location())
* .accountTier("Standard")
* .accountReplicationType("LRS")
* .build());
*
* var exampleKeyVault = new KeyVault("exampleKeyVault", KeyVaultArgs.builder()
* .name("keyvaultname")
* .location(example.location())
* .resourceGroupName(example.name())
* .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
* .skuName("standard")
* .accessPolicies(KeyVaultAccessPolicyArgs.builder()
* .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
* .objectId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
* .secretPermissions(
* "Get",
* "Delete")
* .storagePermissions(
* "Get",
* "List",
* "Set",
* "SetSAS",
* "GetSAS",
* "DeleteSAS",
* "Update",
* "RegenerateKey")
* .build())
* .build());
*
* var exampleManagedStorageAccount = new ManagedStorageAccount("exampleManagedStorageAccount", ManagedStorageAccountArgs.builder()
* .name("examplemanagedstorage")
* .keyVaultId(exampleKeyVault.id())
* .storageAccountId(exampleAccount.id())
* .storageAccountKey("key1")
* .regenerateKeyAutomatically(false)
* .regenerationPeriod("P1D")
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ### Automatically Regenerate Storage Account Access Key)
*
* <!--Start PulumiCodeChooser -->
*
* {@code
* package generated_program;
*
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.azure.core.CoreFunctions;
* import com.pulumi.azuread.AzureadFunctions;
* import com.pulumi.azuread.inputs.GetServicePrincipalArgs;
* import com.pulumi.azure.core.ResourceGroup;
* import com.pulumi.azure.core.ResourceGroupArgs;
* import com.pulumi.azure.storage.Account;
* import com.pulumi.azure.storage.AccountArgs;
* import com.pulumi.azure.keyvault.KeyVault;
* import com.pulumi.azure.keyvault.KeyVaultArgs;
* import com.pulumi.azure.keyvault.inputs.KeyVaultAccessPolicyArgs;
* import com.pulumi.azure.authorization.Assignment;
* import com.pulumi.azure.authorization.AssignmentArgs;
* import com.pulumi.azure.keyvault.ManagedStorageAccount;
* import com.pulumi.azure.keyvault.ManagedStorageAccountArgs;
* import com.pulumi.resources.CustomResourceOptions;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
*
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
*
* public static void stack(Context ctx) {
* final var current = CoreFunctions.getClientConfig();
*
* final var test = AzureadFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
* .applicationId("cfa8b339-82a2-471a-a3c9-0fc0be7a4093")
* .build());
*
* var example = new ResourceGroup("example", ResourceGroupArgs.builder()
* .name("example-resources")
* .location("West Europe")
* .build());
*
* var exampleAccount = new Account("exampleAccount", AccountArgs.builder()
* .name("storageaccountname")
* .resourceGroupName(example.name())
* .location(example.location())
* .accountTier("Standard")
* .accountReplicationType("LRS")
* .build());
*
* var exampleKeyVault = new KeyVault("exampleKeyVault", KeyVaultArgs.builder()
* .name("keyvaultname")
* .location(example.location())
* .resourceGroupName(example.name())
* .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
* .skuName("standard")
* .accessPolicies(KeyVaultAccessPolicyArgs.builder()
* .tenantId(current.applyValue(getClientConfigResult -> getClientConfigResult.tenantId()))
* .objectId(current.applyValue(getClientConfigResult -> getClientConfigResult.objectId()))
* .secretPermissions(
* "Get",
* "Delete")
* .storagePermissions(
* "Get",
* "List",
* "Set",
* "SetSAS",
* "GetSAS",
* "DeleteSAS",
* "Update",
* "RegenerateKey")
* .build())
* .build());
*
* var exampleAssignment = new Assignment("exampleAssignment", AssignmentArgs.builder()
* .scope(exampleAccount.id())
* .roleDefinitionName("Storage Account Key Operator Service Role")
* .principalId(test.applyValue(getServicePrincipalResult -> getServicePrincipalResult.id()))
* .build());
*
* var exampleManagedStorageAccount = new ManagedStorageAccount("exampleManagedStorageAccount", ManagedStorageAccountArgs.builder()
* .name("examplemanagedstorage")
* .keyVaultId(exampleKeyVault.id())
* .storageAccountId(exampleAccount.id())
* .storageAccountKey("key1")
* .regenerateKeyAutomatically(true)
* .regenerationPeriod("P1D")
* .build(), CustomResourceOptions.builder()
* .dependsOn(exampleAssignment)
* .build());
*
* }
* }
* }
*
* <!--End PulumiCodeChooser -->
*
* ## Import
*
* Key Vault Managed Storage Accounts can be imported using the `resource id`, e.g.
*
* ```sh
* $ pulumi import azure:keyvault/managedStorageAccount:ManagedStorageAccount example https://example-keyvault.vault.azure.net/storage/exampleStorageAcc01
* ```
*
*/
@ResourceType(type="azure:keyvault/managedStorageAccount:ManagedStorageAccount")
public class ManagedStorageAccount extends com.pulumi.resources.CustomResource {
/**
* The ID of the Key Vault where the Managed Storage Account should be created. Changing this forces a new resource to be created.
*
*/
@Export(name="keyVaultId", refs={String.class}, tree="[0]")
private Output keyVaultId;
/**
* @return The ID of the Key Vault where the Managed Storage Account should be created. Changing this forces a new resource to be created.
*
*/
public Output keyVaultId() {
return this.keyVaultId;
}
/**
* The name which should be used for this Key Vault Managed Storage Account. Changing this forces a new Key Vault Managed Storage Account to be created.
*
*/
@Export(name="name", refs={String.class}, tree="[0]")
private Output name;
/**
* @return The name which should be used for this Key Vault Managed Storage Account. Changing this forces a new Key Vault Managed Storage Account to be created.
*
*/
public Output name() {
return this.name;
}
/**
* Should Storage Account access key be regenerated periodically?
*
* > **NOTE:** Azure Key Vault application needs to have access to Storage Account for auto regeneration to work. Example can be found above.
*
*/
@Export(name="regenerateKeyAutomatically", refs={Boolean.class}, tree="[0]")
private Output* @Nullable */ Boolean> regenerateKeyAutomatically;
/**
* @return Should Storage Account access key be regenerated periodically?
*
* > **NOTE:** Azure Key Vault application needs to have access to Storage Account for auto regeneration to work. Example can be found above.
*
*/
public Output> regenerateKeyAutomatically() {
return Codegen.optional(this.regenerateKeyAutomatically);
}
/**
* How often Storage Account access key should be regenerated. Value needs to be in [ISO 8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations).
*
*/
@Export(name="regenerationPeriod", refs={String.class}, tree="[0]")
private Output* @Nullable */ String> regenerationPeriod;
/**
* @return How often Storage Account access key should be regenerated. Value needs to be in [ISO 8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations).
*
*/
public Output> regenerationPeriod() {
return Codegen.optional(this.regenerationPeriod);
}
/**
* The ID of the Storage Account.
*
*/
@Export(name="storageAccountId", refs={String.class}, tree="[0]")
private Output storageAccountId;
/**
* @return The ID of the Storage Account.
*
*/
public Output storageAccountId() {
return this.storageAccountId;
}
/**
* Which Storage Account access key that is managed by Key Vault. Possible values are `key1` and `key2`.
*
*/
@Export(name="storageAccountKey", refs={String.class}, tree="[0]")
private Output storageAccountKey;
/**
* @return Which Storage Account access key that is managed by Key Vault. Possible values are `key1` and `key2`.
*
*/
public Output storageAccountKey() {
return this.storageAccountKey;
}
/**
* A mapping of tags which should be assigned to the Key Vault Managed Storage Account. Changing this forces a new resource to be created.
*
*/
@Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]")
private Output* @Nullable */ Map> tags;
/**
* @return A mapping of tags which should be assigned to the Key Vault Managed Storage Account. Changing this forces a new resource to be created.
*
*/
public Output>> tags() {
return Codegen.optional(this.tags);
}
/**
*
* @param name The _unique_ name of the resulting resource.
*/
public ManagedStorageAccount(java.lang.String name) {
this(name, ManagedStorageAccountArgs.Empty);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
*/
public ManagedStorageAccount(java.lang.String name, ManagedStorageAccountArgs args) {
this(name, args, null);
}
/**
*
* @param name The _unique_ name of the resulting resource.
* @param args The arguments to use to populate this resource's properties.
* @param options A bag of options that control this resource's behavior.
*/
public ManagedStorageAccount(java.lang.String name, ManagedStorageAccountArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:keyvault/managedStorageAccount:ManagedStorageAccount", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false);
}
private ManagedStorageAccount(java.lang.String name, Output id, @Nullable ManagedStorageAccountState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
super("azure:keyvault/managedStorageAccount:ManagedStorageAccount", name, state, makeResourceOptions(options, id), false);
}
private static ManagedStorageAccountArgs makeArgs(ManagedStorageAccountArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
if (options != null && options.getUrn().isPresent()) {
return null;
}
return args == null ? ManagedStorageAccountArgs.Empty : args;
}
private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) {
var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
.version(Utilities.getVersion())
.build();
return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
}
/**
* Get an existing Host resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state
* @param options Optional settings to control the behavior of the CustomResource.
*/
public static ManagedStorageAccount get(java.lang.String name, Output id, @Nullable ManagedStorageAccountState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
return new ManagedStorageAccount(name, id, state, options);
}
}