Skip to content

azurermApiManagementSubscription

Manages a Subscription within a API Management Service.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const dataAzurermApiManagementExample =
  new azurerm.dataAzurermApiManagement.DataAzurermApiManagement(
    this,
    "example",
    {
      name: "example-apim",
      resource_group_name: "example-resources",
    }
  );
const dataAzurermApiManagementProductExample =
  new azurerm.dataAzurermApiManagementProduct.DataAzurermApiManagementProduct(
    this,
    "example_1",
    {
      api_management_name: dataAzurermApiManagementExample.name,
      product_id: "00000000-0000-0000-0000-000000000000",
      resource_group_name: dataAzurermApiManagementExample.resourceGroupName,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermApiManagementProductExample.overrideLogicalId("example");
const dataAzurermApiManagementUserExample =
  new azurerm.dataAzurermApiManagementUser.DataAzurermApiManagementUser(
    this,
    "example_2",
    {
      api_management_name: dataAzurermApiManagementExample.name,
      resource_group_name: dataAzurermApiManagementExample.resourceGroupName,
      user_id: "11111111-1111-1111-1111-111111111111",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermApiManagementUserExample.overrideLogicalId("example");
const azurermApiManagementSubscriptionExample =
  new azurerm.apiManagementSubscription.ApiManagementSubscription(
    this,
    "example_3",
    {
      api_management_name: dataAzurermApiManagementExample.name,
      display_name: "Parser API",
      product_id: dataAzurermApiManagementProductExample.id,
      resource_group_name: dataAzurermApiManagementExample.resourceGroupName,
      user_id: dataAzurermApiManagementUserExample.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermApiManagementSubscriptionExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • apiManagementName - (Required) The name of the API Management Service where this Subscription should be created. Changing this forces a new resource to be created.

  • displayName - (Required) The display name of this Subscription.

  • resourceGroupName - (Required) The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.

  • productId - (Optional) The ID of the Product which should be assigned to this Subscription. Changing this forces a new resource to be created.

-> Info: Only one of productId and apiId can be set. If both are missing allApis scope is used for the subscription.

  • userId - (Optional) The ID of the User which should be assigned to this Subscription. Changing this forces a new resource to be created.

  • apiId - (Optional) The ID of the API which should be assigned to this Subscription. Changing this forces a new resource to be created.

-> Info: Only one of productId and apiId can be set. If both are missing /apis scope is used for the subscription and all apis are accessible.

  • primaryKey - (Optional) The primary subscription key to use for the subscription.

  • secondaryKey - (Optional) The secondary subscription key to use for the subscription.


  • state - (Optional) The state of this Subscription. Possible values are active, cancelled, expired, rejected, submitted and suspended. Defaults to submitted.

  • subscriptionId - (Optional) An Identifier which should used as the ID of this Subscription. If not specified a new Subscription ID will be generated. Changing this forces a new resource to be created.

  • allowTracing - (Optional) Determines whether tracing can be enabled. Defaults to true.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The ID of the API Management Subscription.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the API Management Subscription.
  • update - (Defaults to 30 minutes) Used when updating the API Management Subscription.
  • read - (Defaults to 5 minutes) Used when retrieving the API Management Subscription.
  • delete - (Defaults to 30 minutes) Used when deleting the API Management Subscription.

Import

API Management Subscriptions can be imported using the resourceId, e.g.

terraform import azurerm_api_management_subscription.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-resources/providers/Microsoft.ApiManagement/service/example-apim/subscriptions/subscription-name