ऐसी सेवा डिप्लॉय करें जो कैटलॉग में नहीं है
जब कैटलॉग में किसी क्लाउड सेवा के लिए कोई Component नहीं है, तब उस सेवा के रिसोर्स टाइप का वेंडर का अपना वर्णन उसकी जगह ले सकता है। aggrega import उस वर्णन को पढ़ता है — वह स्कीमा जिसे कोई क्लाउड वेंडर किसी रिसोर्स टाइप के लिए प्रकाशित करता है — और उससे दो फ़ाइलें ड्राफ़्ट करता है: एक Component, जो टाइप की सेटिंग उन स्तंभों में घोषित करता है जिन्हें Aggrega पढ़ता है, और एक Recipe, जो उस टाइप का ठीक एक रिसोर्स लिखकर किसी प्रोवाइडर के लिए उस Component को रियलाइज़ करता है। आप ड्राफ़्ट की समीक्षा करते हैं, उन्हें उपयोग करने वाली पंक्तियाँ किसी Aggregate और Release में जोड़ते हैं, और बिल्ड करते हैं।
तीन फ़ॉर्मेट पढ़े जाते हैं, हर एक उस कोर इम्पोर्टर द्वारा जो उसे परोसता है:
| फ़ॉर्मेट | आप जो स्कीमा एक्सपोर्ट करते हैं | Recipe का प्रोवाइडर |
|---|---|---|
cloudformation-schema | CloudFormation रिसोर्स टाइप, aws cloudformation describe-type से या प्रोवाइडर स्कीमा फ़ाइल से | cloudformation |
terraform-schema | Terraform या OpenTofu प्रोवाइडर का स्कीमा, terraform providers schema -json से | terraform |
arm-schema | Azure रिसोर्स प्रोवाइडर की Bicep टाइप फ़ाइल, types.json | arm |
यह पेज Azure का मामला शुरू से अंत तक चलाकर दिखाता है, फिर CloudFormation और Terraform के मामले, और एक ऐसा रूप जो ऐसे Component के लिए केवल एक Recipe ड्राफ़्ट करता है जो कैटलॉग में पहले से है। नीचे Azure वाले हिस्सों के कमांड और आउटपुट कंपाइलर रिलीज़ के उस बिल्ड के रन से हैं जिसमें ये इम्पोर्टर और arm प्रोवाइडर हैं।
आपकी ओर से कुछ भी फ़ेच नहीं किया जाता। आप स्कीमा वेंडर के अपने टूल से एक्सपोर्ट करते हैं, इसलिए इम्पोर्ट वह फ़ाइल पढ़ता है जो आपके पास है और किसी क्लाउड अकाउंट तक नहीं पहुँचता।
स्कीमा एक्सपोर्ट करें
हर वेंडर का टूल स्कीमा को एक फ़ाइल में लिखता है। किसी वर्कस्पेस में, अपने क्लाउड वाला टूल चलाएँ:
# CloudFormation: any registered type, third-party and private ones included.aws cloudformation describe-type --type RESOURCE --type-name AWS::SQS::Queue > sqs-queue.json
# Terraform or OpenTofu: in a directory whose configuration requires the provider.terraform init && terraform providers schema -json > schema.json
# Azure: no export is needed. Bicep's type files are published in the# Azure/bicep-types-az repository, one for each resource provider and API# version, at generated/<namespace>/<provider>/<apiVersion>/types.json.नीचे का Azure मामला Microsoft.ManagedIdentity की उस फ़ाइल का उपयोग करता है जो API संस्करण 2024-11-30 की है, और msi नाम के फ़ोल्डर में उस नाम से रखी है जो Bicep उसे देता है, types.json।
Azure स्कीमा फ़ाइल और उसका लाइसेंस
2024-11-30 पर Microsoft.ManagedIdentity की types.json Azure/bicep-types-az रिपॉज़िटरी की एक फ़ाइल है, कॉपीराइट Microsoft Corporation, MIT License के अंतर्गत वितरित। नीचे के ड्राफ़्ट जिन विवरणों को उद्धृत करते हैं वे Microsoft के हैं, और लाइसेंस की सूचना उन पर लागू होती है:
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWAREवर्कस्पेस वह फ़ोल्डर है जिसमें workspace कुंजी वाली एक .aggrega-config.yaml है, और फ़ाइल के साथ msi फ़ोल्डर:
.aggrega-config.yamlmsi/types.jsonड्राफ़्ट किए जाने वाले टाइप सूचीबद्ध करें
एक स्कीमा फ़ाइल में एक से अधिक रिसोर्स टाइप हो सकते हैं, और इम्पोर्ट केवल उन्हीं को ड्राफ़्ट करता है जिनका आप नाम लेते हैं। देखें कि फ़ाइल में क्या है:
jq -r '.[] | select(."$type" == "ResourceType") | .name' msi/types.jsonMicrosoft.ManagedIdentity/userAssignedIdentities@2024-11-30Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2024-11-30Microsoft.ManagedIdentity/identities@2024-11-30फिर जो टाइप आप चाहते हैं उसका नाम .aggrega-config.yaml में इम्पोर्टर की प्रविष्टि की resource_types सेटिंग के अंतर्गत दें। हर वर्कस्पेस इम्पोर्टर को पहले से परोसता है, इसलिए प्रविष्टि केवल resource_types पास करने के लिए चाहिए। उसका uri इम्पोर्टर और कंपाइलर के उस संस्करण का नाम देता है जिसे aggrega version प्रिंट करता है; इम्पोर्टर को उसकी सेटिंग ऐसी ही किसी प्रविष्टि के ज़रिए सौंपी जाती है, जैसा कौन-सा इम्पोर्टर सोर्स को ड्राफ़्ट में बदलता है बताता है:
workspace: {}default_registry: hub.aggrega.aiplugins: importer: - uri: importer/arm-schema:<compiler version> with: settings: resource_types: - Microsoft.ManagedIdentity/userAssignedIdentitiesCloudFormation (AWS::SQS::Queue) और Terraform (aws_sqs_queue) के लिए नाम ठीक-ठीक मिलाए जाते हैं, और Azure के लिए अक्षरों के आकार की परवाह किए बिना, जहाँ नाम के बाद @ पर एक API संस्करण हो सकता है। जिस फ़ाइल में ठीक एक टाइप है उसे सूची की ज़रूरत नहीं। कई टाइप वाली फ़ाइल का, बिना सूची के, इम्पोर्ट रुक जाता है और उन्हें नाम से बताता है:
halt: the sources hold 3 resource types and the resource_types setting names none: write the types to draft in it, one of Microsoft.ManagedIdentity/userAssignedIdentities, Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials, Microsoft.ManagedIdentity/identitiesसूचीबद्ध ऐसा टाइप जो फ़ाइल में नहीं है, वह भी इम्पोर्ट को रोक देता है, और उन निकटतम नामों को बताता है जो फ़ाइल में हैं। रुकने पर कुछ ड्राफ़्ट नहीं होता, इसलिए कोई फ़ाइल नहीं लिखी जाती।
इम्पोर्ट चलाएं
फ़ोल्डर का नाम दें, या फ़ाइल का:
aggrega import msiस्टैंडर्ड आउटपुट पर यह सूची देता है कि इसने क्या लिखा:
wrote catalog/component/imported/security/microsoft-managedidentity-userassignedidentities/0.1.0/component.yamlwrote catalog/recipe/arm/microsoft-managedidentity-userassignedidentities/0.1.0/recipe.yamlwrote .aggrega-import.jsonस्टैंडर्ड एरर पर, जहाँ <workspace> उस फ़ोल्डर के स्थान पर है जिसमें आपने इसे चलाया:
read as the arm-schema format, with drafted paths relative to <workspace>mapped Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30 (Microsoft.ManagedIdentity/userAssignedIdentities) to imported/security/microsoft-managedidentity-userassignedidentities as a draft, NONE at 0.05aggrega import types.json नाम की Bicep टाइप फ़ाइल को पहचानता है, जैसे Azure/bicep-types-az उन्हें नाम देता है, और किसी अन्य नाम की फ़ाइल के लिए --format arm-schema फ़ॉर्मेट का नाम देता है। --format किसी बड़े एक्सपोर्ट, जैसे किसी प्रोवाइडर का पूरा Terraform स्कीमा, को इम्पोर्ट करने का भी तरीका है, बिना इसके कि इम्पोर्ट पहले उसे पहचाने।
mapped पंक्ति बताती है कि रिसोर्स टाइप अपना ही एक ड्राफ़्ट बन गया, जिसके पास कैटलॉग का कोई Component नहीं था। ड्राफ़्ट catalog/ के अंतर्गत लिखे जाते हैं, वह फ़ोल्डर जिसे वर्कस्पेस कैटलॉग के रूप में पढ़ता है, इसलिए वे अगले वैलिडेट और बिल्ड पर कुछ कॉन्फ़िगर किए बिना रिज़ॉल्व हो जाते हैं। रिकॉर्ड .aggrega-import.json उन्हें सूचीबद्ध करता है, ताकि aggrega import --sync उन्हें बदले हुए स्कीमा के साथ अद्यतन कर सके, आपके किसी संपादन को अधिलेखित किए बिना।
ड्राफ़्ट क्या कहते हैं
Component, component.yaml, रिसोर्स टाइप की हर प्रॉपर्टी को एक स्तंभ में रखता है, और हर कुंजी के बगल की टिप्पणी उस नियम का नाम बताती है जिसने उसे वहाँ रखा:
- रीड-बैक प्रॉपर्टी, यानी जिसे क्लाउड सेट करता है और आप नहीं कर सकते, इनपुट नहीं है। स्केलर एक
providesकुंजी बन जाता है जिसे कोई उपभोक्ता पढ़ सकता है। - सीक्रेट को उस जगह के रेफ़रेंस के रूप में ड्राफ़्ट किया जाता है जहाँ से उसका मान आता है, कभी मान के रूप में नहीं, जैसा नीचे सीक्रेट बताता है।
- प्लेसमेंट, यानी रिसोर्स कहाँ रहता है, जैसे Azure का
location,infraमें जाता है, वह स्तंभ जो ऑपरेटर हर एनवायरनमेंट के लिए देता है। - आइडेंटिटी, यानी रिसोर्स का अपना नाम,
valuesमें जाती है, वह स्तंभ जिसे डेवलपर लिखता है। - कोई भी अन्य आवश्यक प्रॉपर्टी
infraमें जाती है। - हर अन्य लिखने योग्य प्रॉपर्टी
infra.overridesके अंतर्गत जाती है, एक खुला मैप जो हर नाम की वर्तनी वैसी ही रखता है जैसी वेंडर की है।
इस रिसोर्स टाइप के लिए Component इस प्रकार पढ़ता है:
apiVersion: aggrega.ai/v1beta1kind: Componentmetadata: name: imported/security/microsoft-managedidentity-userassignedidentities version: 0.1.0 description: "Draft Component of the resource type Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30, imported from a source in the arm-schema format." labels: component.aggrega.ai/type: resource component.aggrega.ai/category: security component.aggrega.ai/hosting: managedspec: schema: values: type: object properties: # identity: the resource's own name or identifier # [vendor schema text] The resource name name: type: string description: "[vendor schema text] The resource name" required: true additionalProperties: false infra: type: object properties: # placement: where the resource is deployed # [vendor schema text] The geo-location where the resource lives location: type: string description: "[vendor schema text] The geo-location where the resource lives" required: true # override: every writable property no other rule places, each under the vendor's own name overrides: type: object description: "Writable settings of Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30, each under the vendor's own name, which the Recipe passes to the resource as written; its header lists the names it reads." additionalProperties: true additionalProperties: false provides: type: object properties: # read back: published under provides # [vendor schema text] The resource id id: type: string description: "[vendor schema text] The resource id" # … client_id, principal_id and tenant_id, each read back the same way additionalProperties: falseड्राफ़्ट वेंडर के स्कीमा से जो भी टेक्स्ट लेता है वह [vendor schema text] से शुरू होता है, ताकि Component आपके वर्कस्पेस से बाहर जाने से पहले आप उन्हें ढूँढकर अपने शब्दों में फिर से लिख सकें। इम्पोर्ट जो टेक्स्ट स्वयं रचता है उस पर कोई चिह्न नहीं होता।
Recipe, recipe.yaml, Component को arm प्रोवाइडर पर रियलाइज़ करता है। उसकी हेडर टिप्पणी हर उस कुंजी को, उसके नियम और टाइप के साथ, सूचीबद्ध करती है जिसे वह पढ़ता है, और यह भी कि वह क्या नहीं पढ़ता:
spec: # This Recipe realizes imported/security/microsoft-managedidentity-userassignedidentities with one resource of the type Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30. It reads the keys below, each with its type, its rule and the first sentence of the vendor's description; any other key under infra.overrides halts the build naming it. # infra.location: string, required; placement: where the resource is deployed # [… omitted: the first sentence of the vendor's description of the key above, marked as vendor schema text, as below each key] # values.name: string, required; identity: the resource's own name or identifier # [… omitted: the vendor's description of the key] # infra.overrides.tags: object; override: writable, set under infra.overrides in the vendor's spelling # [… omitted: the vendor's description of the key] # infra.overrides.isolationScope: string; override: writable, set under infra.overrides in the vendor's spelling # [… omitted: the vendor's description of the key, then a line saying template.yaml declares the resource under the symbolic name locals.symbol holds] capability: arm implements: imported/security/microsoft-managedidentity-userassignedidentities:0.1.0 locals: # [… omitted: a comment saying what the symbolic name is made of] symbol: "{{ capitalizedWords .context.instance_id }}" provides: # [… omitted: a comment saying each value is one whole ARM expression, evaluated when the template is deployed] id: "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities'{{ range splitList \"/\" (toString (index .values \"name\")) }}, '{{ replace \"'\" \"''\" . }}'{{ end }})]" client_id: "[reference('{{ .locals.symbol }}').clientId]" # … principal_id and tenant_id the same way assertions: overrides_this_recipe_reads: | # halts naming any key under infra.overrides the header does not list artifacts: template.yaml: | # … the resource, written under the symbolic name locals.symbol holdsRecipe एक रिसोर्स लिखता है, वही जिसका नाम टाइप देता है, और कुछ नहीं: न कोई रिसोर्स ग्रुप, न नेटवर्क, न कोई ऐसी आइडेंटिटी जो आपने घोषित नहीं की। हर provides मान एक पूरा एक्सप्रेशन है जिसे Azure टेम्पलेट डिप्लॉय होने पर मूल्यांकित करता है, और जो उपभोक्ता को उसी स्ट्रिंग के रूप में दिया जाता है जो वह है। infra.overrides की ऐसी कुंजी जो हेडर सूचीबद्ध नहीं करता, उसका नाम लेते हुए बिल्ड को रोक देती है, इसलिए गलत वर्तनी वाली सेटिंग किसी भी डिप्लॉयमेंट से पहले पकड़ ली जाती है।
बिल्ड करने से पहले दोनों फ़ाइलों की समीक्षा करें। किसी सेटिंग को एक स्तंभ से दूसरे में ले जाना Component का और उसे पढ़ने वाले Recipe का संपादन है, और फ़ाइलें आपकी हैं: बिल्ड जिन पर निर्भर करता है वह कहीं और नहीं रखा है।
ड्राफ़्ट को Aggregate और Release में उपयोग करें
इम्पोर्ट कोई Aggregate, कोई Manifest और कोई Release ड्राफ़्ट नहीं करता, इसलिए ड्राफ़्ट किए गए Component को उपयोग करने वाली पंक्तियाँ आपकी हैं। Aggregate, aggregate.yaml, में ड्राफ़्ट किए गए टाइप का एक घटक, जो वह आइडेंटिटी वहन करता है जिसे values स्तंभ रखता है:
apiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: identities version: 1.0.0spec: components: deploy-identity: type: imported/security/microsoft-managedidentity-userassignedidentities:0.1.0 values: name: deploy-identityManifest, manifest.yaml, में एक पंक्ति जो बताती है कि टाइप को कौन-सा Recipe रियलाइज़ करता है:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: identities version: 1.0.0spec: mappings: components: type: imported/security/microsoft-managedidentity-userassignedidentities:0.1.0: arm/microsoft-managedidentity-userassignedidentities:0.1.0Release, release.yaml, में वह बाउंड्री जिसमें घटक पहुँचता है और वह infra स्तंभ जिसकी Recipe को ज़रूरत है, यानी प्लेसमेंट:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: identities version: 1.0.0 environment: productionspec: aggregate: ./aggregate.yaml manifest: ./manifest.yaml boundaries: azure: directory: azure components: deploy-identity: infra: location: westeuropeवैलिडेट और बिल्ड करें
aggrega validate --release release.yamlrelease dependency validation passed: release.yaml (schema-pillar + dependency pillars)वह सब पुल करें जिस पर Release निर्भर है, फिर बिल्ड करें:
aggrega pull --release release.yamlaggrega build --release release.yamlPull complete: release.lock (entities=…, source_artifacts=…, external_inputs=…)[… omitted: the build's elapsed time]Build completed: 1 file written to <workspace>/distबिल्ड dist/azure/arm/arm-template.json लिखता है, जो azure बाउंड्री का एक टेम्पलेट है, जिसमें एक रिसोर्स है, उस सिंबॉलिक नाम के अंतर्गत जो उसका इंस्टेंस उसे देता है। रिसोर्स के अपने सदस्यों के बगल में, बिल्ड metadata के अंतर्गत दर्ज करता है कि किस Aggregate, Release और Recipe ने उसे बनाया:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "languageVersion": "2.0", "resources": { "DeployIdentity": { "apiVersion": "2024-11-30", "location": "westeurope", "metadata": { "aggrega.ai/provenance": { "aggrega.ai/aggregate-name": "identities", "aggrega.ai/boundary-path": "azure", "aggrega.ai/compiler-version": "<compiler version>", "aggrega.ai/component-id": "deploy-identity", "aggrega.ai/environment": "production", "aggrega.ai/provider": "arm", "aggrega.ai/provider-version": "<compiler version>", "aggrega.ai/recipe-uri": "microsoft-managedidentity-userassignedidentities:0.1.0" } }, "name": "deploy-identity", "type": "Microsoft.ManagedIdentity/userAssignedIdentities" } }}टेम्पलेट वही है जो आप Azure को देते हैं; arm प्रोवाइडर वे कमांड बताता है जो उसे रिसोर्स-ग्रुप स्कोप पर डिप्लॉय करते हैं। ऐसा रिसोर्स टाइप जो केवल सब्सक्रिप्शन या मैनेजमेंट-ग्रुप स्कोप पर लिखने योग्य है, उस स्कोप के लिए एक फ़्रैगमेंट के रूप में ड्राफ़्ट किया जाता है, और उसके Recipe का हेडर वह बाउंड्री एनोटेशन बताता है जो Release सेट करता है, जैसा सब्सक्रिप्शन स्कोप पर डिप्लॉय करना और मैनेजमेंट-ग्रुप स्कोप पर डिप्लॉय करना बताते हैं। जो टाइप केवल टेनेंट स्कोप पर, या केवल किसी अन्य रिसोर्स के एक्सटेंशन के रूप में लिखने योग्य है, उसे नाम लेकर अस्वीकार किया जाता है।
सीक्रेट
सीक्रेट प्रॉपर्टी का मान कभी ड्राफ़्ट में नहीं लिखा जाता, और उसके लिए कोई डिफ़ॉल्ट ड्राफ़्ट नहीं किया जाता। वह रिसोर्स तक कैसे पहुँचता है, यह प्रोवाइडर पर निर्भर है:
- Azure: टेम्पलेट का शीर्ष-स्तरीय
securestringपैरामीटर, जिसका नाम इंस्टेंस और प्रॉपर्टी के नाम पर रखा जाता है, और जिसे आप डिप्लॉय करते समय देते हैं। जिस सीक्रेट को वेंडर वैकल्पिक चिह्नित करता है, वह एक आवश्यक पैरामीटर होता है। - CloudFormation: टेम्पलेट की
Parametersप्रविष्टि जिस परNoEchoलगा है, उसी तरह नामित। जिस सीक्रेट को वेंडर वैकल्पिक चिह्नित करता है, वह एक आवश्यक पैरामीटर होता है। - Terraform: Component पर एक Feature स्लॉट, और एक मॉड्यूल वेरिएबल जिस पर
sensitive: trueलगा है; मान उस सीक्रेट से आता है जिसे Release स्लॉट से अटैच करता है।
केवल रिसोर्स के शीर्ष पर स्थित प्रॉपर्टी ही सीक्रेट बनती है — Azure पर रूट की या properties का सदस्य। उसके नीचे का संवेदनशील सदस्य, जैसे Azure के osProfile के भीतर adminPassword या Terraform ब्लॉक के भीतर password, सीक्रेट के रूप में ड्राफ़्ट नहीं किया जाता: Release उसे उस कुंजी के भीतर साधारण मान के रूप में सेट करता है जिसके अंतर्गत उसका पैरेंट ड्राफ़्ट किया जाता है, और इम्पोर्ट हर ऐसे सदस्य की constraint-dropped के अंतर्गत चेतावनी देता है, उसका पाथ और वह कुंजी बताते हुए।
CloudFormation की प्रॉपर्टी को सीक्रेट के रूप में तब पढ़ा जाता है जब उसके नाम में कोई क्रेडेंशियल शब्द हो — password, secret, token, credential, private key, API key या passphrase — और वह Arn, Id, Name या Ref पर समाप्त न होता हो। यह पठन ड्राफ़्ट की एक परिपाटी है, और Recipe का हेडर हर उस प्रॉपर्टी को चिह्नित करता है जिसे उसने सीक्रेट के रूप में पढ़ा, ताकि आप समीक्षा में उनकी पुष्टि करें।
CloudFormation और Terraform पर वही इम्पोर्ट
चरण वही हैं; केवल एक्सपोर्ट और Recipe का आकार अलग है। नीचे के दोनों मामले कृत्रिम स्कीमा से ड्राफ़्ट किए गए हैं, जिनका वेंडर टेक्स्ट आगे के भाग से हटा दिया गया है।
CloudFormation
aws cloudformation describe-type --type RESOURCE --type-name AWS::Example::Ledger > ledger.jsonaggrega import ledger.jsonइम्पोर्ट एक Component और एक Recipe लिखता है, और हर उस वेंडर कंस्ट्रेंट के लिए एक चेतावनी जिसे वह वहन नहीं कर सकता:
wrote catalog/component/imported/component/aws-example-ledger/0.1.0/component.yamlwrote catalog/recipe/cloudformation/aws-example-ledger/0.1.0/recipe.yamlwrote .aggrega-import.jsonread as the cloudformation-schema format, with drafted paths relative to <workspace>warn: the property "LedgerName" does not carry the vendor schema's pattern "…": the catalog reads a pattern as an RE2 regular expression, which refuses it: …warn: the property "Rules[].Children[]" does not carry the vendor schema's shape below it: the vendor schema's definitions refer back to themselves there, so it is drafted as an open objectmapped AWS::Example::Ledger (AWS::Example::Ledger) to imported/component/aws-example-ledger as a draft, NONE at 0.0167Recipe की template.yaml रिसोर्स को उस लॉजिकल id के अंतर्गत घोषित करती है जो इंस्टेंस उसे देता है, सीक्रेट को NoEcho पैरामीटर के रूप में, और हर provides कुंजी को !Ref या !GetAtt के रूप में लिखकर, जिसे provides के अंतर्गत दोहराया जाता है ताकि cloudformation प्रोवाइडर उसे स्टैक के Outputs में प्रोजेक्ट करे:
artifacts: template.yaml: | Parameters: {{ .locals.logical_id }}MasterPassword: Type: String NoEcho: true Resources: {{ .locals.logical_id }}: Type: AWS::Example::Ledger Properties: # … one line for each key the header lists MasterPassword: !Ref {{ .locals.logical_id }}MasterPassword provides: arn: !GetAtt {{ .locals.logical_id }}.ArnTerraform
terraform init && terraform providers schema -json > schema.jsonaggrega import schema.jsonwrote catalog/component/imported/component/aws-example-ledger/0.1.0/component.yamlwrote catalog/recipe/terraform/aws-example-ledger/0.1.0/recipe.yamlwrote catalog/recipe/terraform/aws-example-ledger/0.1.0/module/main.tf.jsonwrote .aggrega-import.jsonTerraform एक्सपोर्ट उन प्रोवाइडरों के नाम देता है जिनकी कॉन्फ़िगरेशन को ज़रूरत है, और उनका कोई संस्करण नहीं देता, इसलिए इम्पोर्ट चेतावनी देता है:
warn: no version of the provider hashicorp/aws is known, so the module drafted for aws_example_ledger requires it without a version constraint: set terraform.required_providers.aws.version in the module/main.tf.json beside the Recipe, then run aggrega pin on the RecipeTerraform ड्राफ़्ट एक Recipe है जिसके बगल में एक मॉड्यूल है। module/main.tf.json हर इनपुट के लिए एक वेरिएबल घोषित करता है, एक रिसोर्स, this, जिसका हर आर्ग्युमेंट अपने वेरिएबल से पढ़ा जाता है, और वह प्रोवाइडर जिसका नाम एक्सपोर्ट देता है। Recipe का spec.source मॉड्यूल की ओर इंगित करता है, और उसका valuesMapping हर वेरिएबल को Component के स्तंभों से भरता है, वैकल्पिक इनपुट केवल वहीं लिखते हुए जहाँ Release उसे सेट करता है। पहले पुल से पहले मॉड्यूल को पिन करें, ताकि लॉक उसका डाइजेस्ट दर्ज करे:
aggrega pin catalog/recipe/terraform/aws-example-ledger/0.1.0/recipe.yamlPinned Recipe "aws-example-ledger": wrote <workspace>/catalog/recipe/terraform/aws-example-ledger/0.1.0/entity.lock (remote source pins: 0, imported file pins: 0, local source file pins: 1). Commit it beside the entityबिना पिन किया Recipe पुल को रोक देता है, aggrega pin का नाम लेते हुए। मॉड्यूल के हर संपादन के बाद फिर से पिन करें।
Aggregate, Manifest और Release की पंक्तियाँ वही हैं जो Azure के मामले में हैं, ड्राफ़्ट किए गए नामों और प्रोवाइडर के अपने infra के साथ: Terraform Release प्रोवाइडर की प्लेसमेंट कुंजियों के नाम लेता है, जैसे region, जहाँ Component उन्हें घोषित करता है।
ऐसा Component जो कैटलॉग में पहले से है
जब कैटलॉग में सेवा के लिए Component है, और केवल आपके प्रोवाइडर के लिए Recipe नहीं है, तब सेटिंग में उस Component का नाम दें। इम्पोर्ट तब केवल Recipe ड्राफ़्ट करता है, जो Component के स्तंभों के विरुद्ध लिखा जाता है। resource_types की हर प्रविष्टि या तो टाइप का नाम है, या एक ऑब्जेक्ट जिसमें टाइप और Component हैं:
plugins: importer: # The entry passes resource_types; the importer is served without it. - uri: importer/arm-schema:<compiler version> with: settings: resource_types: - type: Microsoft.ManagedIdentity/userAssignedIdentities component: acme/security/identityRecipe का नाम Component के नाम पर identity-microsoft-managedidentity-userassignedidentities रखा जाता है, ताकि वह कभी उस Recipe का नाम न ले जो कैटलॉग में पहले से है। कैटलॉग का ऐसा Component जो टाइप की किसी प्रॉपर्टी जैसे नाम की values कुंजी घोषित करता है, उस प्रॉपर्टी को values से पढ़ता है; वह प्रॉपर्टी जो वेंडर के लिए आवश्यक है और जिसके लिए Component में कोई कुंजी नहीं है, infra.overrides से पढ़ी जाती है, एक एसर्शन के साथ जो बिल्ड को तब तक रोकता है जब तक Release उसे सेट न करे। Component जो हर कुंजी प्रदान करता है और जो नाम से किसी रीड-बैक एट्रिब्यूट से मेल खाती है, वह लिखी जाती है। हर अन्य के लिए, ड्राफ़्ट ऐसा टेम्पलेट लिखता है जो कुंजी का नाम लेते हुए विफल होता है, इसलिए बिल्ड तब तक रुकता है जब तक आप उसे मैप न करें, और इम्पोर्ट चेतावनी देता है:
warn: the Component acme/security/identity provides principal_id, and no attribute Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30 reads back carries its name, so the drafted Recipe's provides.principal_id halts the build until it is mapped: map it to an attribute Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30 reads back, one of id, properties.clientId, properties.principalId, properties.tenantIdAzure इस एट्रिब्यूट को properties के अंतर्गत नेस्ट करता है, इसलिए लिखने की पंक्ति वही है जो टाइप का पूरा ड्राफ़्ट रखता है:
provides: principal_id: "[reference('{{ .locals.symbol }}').principalId]"वह पंक्ति लिखे जाने पर, Release Component का नाम अपने Aggregate में और Recipe का नाम अपने Manifest में ऊपर की तरह देता है, प्लेसमेंट infra.overrides.location के अंतर्गत सेट करता है, और उसी टेम्पलेट पर वैलिडेट और बिल्ड होता है।
ऐसा नाम जिसका कैटलॉग में कोई Component नहीं है, उस नाम के अंतर्गत एक नए Component के रूप में ड्राफ़्ट किया जाता है, और इम्पोर्ट चेतावनी देता है, ताकि किसी Component की गलत वर्तनी वाला नाम नए Component के रूप में न समझ लिया जाए।
आगे कहाँ जाएं
- कोर इम्पोर्टर बताता है कि हर इम्पोर्टर क्या पढ़ता है, वह कई टाइप के बीच और कई प्रोवाइडर के बीच कैसे चुनता है, विभाजन पूरा, हर लक्ष्य क्या ड्राफ़्ट करता है, और तीनों जो डायग्नोस्टिक रिपोर्ट करते हैं।
- arm प्रोवाइडर बताता है कि Azure ड्राफ़्ट जिस टेम्पलेट में मर्ज किया जाता है वह क्या है और वह किन स्कोप पर डिप्लॉय होता है।
- aggrega import कमांड का पूरा संदर्भ है।