Using #Terraform for Marketplace images | IaaS Blog – #Oracle Cloud Infrastructure News

STRATEGY

November 11, 2020Using Terraform for Marketplace imagesJohn ParkerCLOUD SOLUTION ARCHITECTBecause many customers are in the process of building their infrastructure as code, the use cases for Terraform are growing. This is especially true when you’re automating the creation of an environment in Oracle Cloud Infrastructure (OCI) and using OCI Marketplace images. Using Terraform to deploy OCI Marketplace offerings lets you have all of your deployment code in an automated format for deployment and state management.This post provides the basic necessary code for you to use to add OCI Marketplace images into your infrastructure with Terraform. It doesn’t cover creating any of the network or storage portions.Required codeYou need two resource elements and five data elements. The two resource elements are agreements for using the Marketplace image, and the data elements support the resource agreements.Resource elementsThe key resource elements that you need to use a Marketplace image are oci_marketplace_accepted_agreement and oci_marketplace_listing_package_agreement. These agreements also require several data elements to get the signed agreement.Resource element: oci_marketplace_accepted_agreementresource « oci_marketplace_accepted_agreement » « test_accepted_agreement » { #Required agreement_id = oci_marketplace_listing_package_agreement.test_listing_package_agreement.agreement_id compartment_id = var.compartment_id listing_id = data.oci_marketplace_listing.test_listing.id package_version = data.oci_marketplace_listing.test_listing.default_package_version signature = oci_marketplace_listing_package_agreement.test_listing_package_agreement.signature}Resource element: oci_marketplace_listing_package_agreementresource « oci_marketplace_listing_package_agreement » « test_listing_package_agreement » { #Required agreement_id = data.oci_marketplace_listing_package_agreements.test_listing_package_agreements.agreements[0].id listing_id = data.oci_marketplace_listing.test_listing.id package_version = data.oci_marketplace_listing.test_listing.default_package_version}Data elementsTo get the correct data for the resources, you need the following data elements:Agreement IDCompartment IDListing IDPackage versionThe compartment ID is the OCID of the compartment in which you plan to install the Marketplace offering.As a PowerShell user, I like to use the OCI PowerShell toolkit to get the listing ID information. The OCI PowerShell toolkit is in part of the common module, and the command is Get-OCIComputeAppCatalogListingsList. You can also get the display names and IDs of the catalog listings through other means, either from the Marketplace page or through the OCI CLI.The PowerShell command looks as follows:Figure 1: PowerShell output for Marketplace listingsYou can get the same information with the OCI CLI, although you might have to scroll for a bit if you don’t have the name of the Marketplace offering ahead of time.Figure 2: CLI output for Marketplace listingsAfter you have the display name, you’re ready to start looking at the Terraform code. You can use the display name to find the Marketplace image with a Terraform data object.OCI_marketplace_listingdata « oci_marketplace_listings » « test_listings » { name = [« Microsoft SQL 2016 Standard with Windows Server 2016 Standard »] compartment_id = var.compartment_id}After you have the listing ID, then you can start gathering the rest of the information for the agreement resources.Data elementsdata « oci_marketplace_listing_package_agreements » « test_listing_package_agreements » { #Required listing_id = data.oci_marketplace_listing.test_listing.id package_version = data.oci_marketplace_listing.test_listing.default_package_version #Optional compartment_id = var.compartment_id}data « oci_marketplace_listing_package » « test_listing_package » { #Required listing_id = data.oci_marketplace_listing.test_listing.id package_version = data.oci_marketplace_listing.test_listing.default_package_version #Optional compartment_id = var.compartment_id}data « oci_marketplace_listing_packages » « test_listing_packages » { #Required listing_id = data.oci_marketplace_listing.test_listing.id #Optional compartment_id = var.compartment_id}data « oci_marketplace_listing » « test_listing » { listing_id = data.oci_marketplace_listings.test_listings.listings[0].id compartment_id = var.compartment_id}data « oci_core_app_catalog_listing_resource_version » « test_catalog_listing » { listing_id = data.oci_marketplace_listing_package.test_listing_package.app_catalog_listing_id resource_version = data.oci_marketplace_listing_package.test_listing_package.app_catalog_listing_resource_version}Now that you have the agreement, you pass it to the instance information so that you can build the Marketplace offering in your OCI compartment. The resource in this example is oci_core_instance, and we pass to it the source ID from the data.oci_core_app_catalog_listing_resource_versi

Source: Using Terraform for Marketplace images | IaaS Blog – Oracle Cloud Infrastructure News

Publié par Start Export

B2B Import Export Ayatweb in TikTok come support me Ready to teamwork

Un avis sur « Using #Terraform for Marketplace images | IaaS Blog – #Oracle Cloud Infrastructure News »

Laisser un commentaire

Concevoir un site comme celui-ci avec WordPress.com
Commencer