Subscribing Terraform Configurations to Marketplace Images
Create an instance and agreement to subscribe terraform configurations to marketplace images.
To subscribe Terraform configurations to Marketplace images, do the following:
-
Create an Instance from a Published Marketplace Image
To create an instance from a published marketplace image, you must add the following resources in your Terraform configuration:
oci_core_app_catalog_listing_resource_version_agreement
oci_core_app_catalog_subscription
-
Create a Subscription and a Resource Version Agreement
To create a subscription and a resource version agreement, you must provide a:
Listing OCID (mp_listing_id)
Package Version Reference (mp_listing_resource_version)
Marketplace Image OCID (mp_listing_resource_id)
-
Get Values for Listing OCID, Package Version Reference, and Marketplace Image
OCID
To get these values:
- Sign in to Partner Portal.
- Click Listings.
- From the Listings page, click the Published tab.
- Select the Image Listing you are subscribing to, click the menu icon (the four line icon) at the right corner of that row, and selectView Listing.
- In the Edit Listing page, click the App Install Package tab.
- From the Package Versions list, click the version of the Image Listing you're subscribing to.
- From the Define Package Information section, copy the
following values:
Listing OCID (mp_listing_id)
Package Version Reference (mp_listing_resource_version)
- From the Configure OCI Compute Image section, copy the value
of:
Marketplace image ocid (mp_listing_resource_id)
-
Refer the Sample for Creating Marketplace Image Subscription
The following sample creates a Marketplace image subscription. For a complete example see : https://github.com/oracle-quickstart/oci-quickstart-template/blob/master/image_subscription.tf
# Local variables pointing to the Marketplace catalog resource # Eg. Modify accordingly to your Application/Listing locals { mp_listing_id = "${var.mp_listing_id}" mp_listing_resource_id = "${var.mp_listing_resource_id}" mp_listing_resource_version = "${var.mp_listing_resource_version}" } # Get Image Agreement resource "oci_core_app_catalog_listing_resource_version_agreement" "mp_image_agreement" { count = "${var.use_marketplace_image ? 1 : 0}" listing_id = "${local.mp_listing_id}" listing_resource_version = "${local.mp_listing_resource_version}" } # Accept Terms and Subscribe to the image, placing the image in a particular compartment resource "oci_core_app_catalog_subscription" "mp_image_subscription" { count = "${var.use_marketplace_image ? 1 : 0}" compartment_id = "${var.compartment_ocid}" eula_link = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.eula_link}" listing_id = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.listing_id}" listing_resource_version = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.listing_resource_version}" oracle_terms_of_use_link = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.oracle_terms_of_use_link}" signature = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.signature}" time_retrieved = "${oci_core_app_catalog_listing_resource_version_agreement.mp_image_agreement.time_retrieved}" timeouts { create = "20m" } } # Gets the partner image subscription data "oci_core_app_catalog_subscriptions" "mp_image_subscription" { #Required compartment_id = "${var.compartment_ocid}" #Optional listing_id = "${local.mp_listing_id}" filter { name = "listing_resource_version" values = ["${local.mp_listing_resource_version}"] } # Reference the Marketplace Image resource "oci_core_instance" "instance" { // availability_domain = "${data.oci_identity_availability_domain.ad.name}" //... source_details { source_type = "image" source_id = "${var.use_marketplace_image ? local.mp_listing_resource_id : var.custom_image_id}" } timeouts { create = "60m" } }