ข้ามไปยังเนื้อหา
AggregaAggregaAggregaAggrega
เลือกภาษา: ไทย
หน้านี้ถูกแปลด้วยเครื่อง อ่านต้นฉบับภาษาอังกฤษ

ปรับใช้บริการที่แค็ตตาล็อกไม่มี

เมื่อแค็ตตาล็อกไม่มี 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 -jsonterraform
arm-schemaไฟล์ชนิด Bicep ของผู้ให้บริการทรัพยากร Azure คือ types.jsonarm

หน้านี้ทำกรณี Azure ตั้งแต่ต้นจนจบ จากนั้นแสดงกรณี CloudFormation และ Terraform และแบบที่ร่างเฉพาะ Recipe สำหรับ Component ที่แค็ตตาล็อกมีอยู่แล้ว คำสั่งและเอาต์พุตในส่วน Azure ด้านล่างมาจากการรันบิลด์ของรุ่นคอมไพเลอร์ที่มีตัวนำเข้าเหล่านี้และผู้ให้บริการ arm

ไม่มีสิ่งใดถูกดึงแทนคุณ คุณส่งออกสคีมาด้วยเครื่องมือของผู้จำหน่ายเอง การนำเข้าจึงอ่านไฟล์ที่คุณถือไว้และไม่เข้าถึงบัญชีคลาวด์เลย

ส่งออกสคีมา

เครื่องมือของผู้จำหน่ายแต่ละรายเขียนสคีมาลงไฟล์ รันเครื่องมือของคลาวด์ที่คุณใช้ ในพื้นที่ทำงาน:

Terminal window
# 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 และสัญญาอนุญาต

types.json ของ Microsoft.ManagedIdentity ที่ 2024-11-30 เป็นไฟล์ของที่เก็บ 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 copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, 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 THE
SOFTWARE

พื้นที่ทำงานคือโฟลเดอร์ที่มี .aggrega-config.yaml ซึ่งมีคีย์ workspace และโฟลเดอร์ msi ที่มีไฟล์นั้น:

.aggrega-config.yaml
msi/types.json

แสดงรายการชนิดที่จะร่าง

ไฟล์สคีมาอาจมีประเภททรัพยากรมากกว่าหนึ่งประเภท และการนำเข้าจะร่างเฉพาะประเภทที่คุณระบุชื่อ แสดงรายการสิ่งที่ไฟล์มี:

Terminal window
jq -r '.[] | select(."$type" == "ResourceType") | .name' msi/types.json
Microsoft.ManagedIdentity/userAssignedIdentities@2024-11-30
Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials@2024-11-30
Microsoft.ManagedIdentity/identities@2024-11-30

จากนั้นระบุชื่อประเภทที่ต้องการภายใต้การตั้งค่า resource_types ของรายการของตัวนำเข้าใน .aggrega-config.yaml ทุกพื้นที่ทำงานมีตัวนำเข้าอยู่แล้ว รายการนี้จึงจำเป็นเฉพาะเพื่อส่ง resource_types เท่านั้น uri ของรายการระบุตัวนำเข้าและเวอร์ชันของคอมไพเลอร์ ซึ่ง aggrega version พิมพ์ออกมา ตัวนำเข้ารับการตั้งค่าผ่านรายการเช่นนี้ ดังที่ ตัวนำเข้าใดเปลี่ยนซอร์สเป็นฉบับร่าง อธิบาย:

workspace: {}
default_registry: hub.aggrega.ai
plugins:
importer:
- uri: importer/arm-schema:<compiler version>
with:
settings:
resource_types:
- Microsoft.ManagedIdentity/userAssignedIdentities

ชื่อจับคู่แบบตรงตัวสำหรับ CloudFormation (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

ประเภทที่อยู่ในรายการแต่ไฟล์ไม่มีก็หยุดการนำเข้าเช่นกัน โดยระบุชื่อที่ใกล้เคียงที่สุดที่ไฟล์มี การหยุดไม่ร่างสิ่งใด จึงไม่มีไฟล์ถูกเขียน

รันการนำเข้า

ระบุโฟลเดอร์หรือไฟล์:

Terminal window
aggrega import msi

ที่เอาต์พุตมาตรฐาน การนำเข้าแสดงสิ่งที่เขียน:

wrote catalog/component/imported/security/microsoft-managedidentity-userassignedidentities/0.1.0/component.yaml
wrote catalog/recipe/arm/microsoft-managedidentity-userassignedidentities/0.1.0/recipe.yaml
wrote .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.05

aggrega import รู้จักไฟล์ชนิด Bicep ที่ชื่อ types.json ตามที่ Azure/bicep-types-az ตั้งชื่อ และ --format arm-schema ระบุรูปแบบสำหรับไฟล์ที่ตั้งชื่ออย่างอื่น --format ยังเป็นวิธีนำเข้าไฟล์ส่งออกขนาดใหญ่ เช่น สคีมา Terraform ทั้งหมดของผู้ให้บริการ โดยไม่ต้องให้การนำเข้ารู้จักไฟล์ก่อน

บรรทัด mapped บอกว่าประเภททรัพยากรกลายเป็นฉบับร่างของตัวเอง โดยไม่มี Component ในแค็ตตาล็อกที่ใกล้เคียง ฉบับร่างถูกเขียนไว้ใต้ catalog/ ซึ่งเป็นโฟลเดอร์ที่พื้นที่ทำงานอ่านเป็นแค็ตตาล็อก จึงหาค่าได้ในการตรวจสอบความถูกต้องและบิลด์ครั้งถัดไปโดยไม่ต้องกำหนดค่าอะไร บันทึก .aggrega-import.json แสดงรายการฉบับร่างเหล่านั้น aggrega import --sync จึงอัปเดตให้ตรงกับสคีมาที่เปลี่ยนได้โดยไม่เขียนทับการแก้ไขของคุณ

สิ่งที่ฉบับร่างบอก

Component คือ component.yaml จัดแต่ละคุณสมบัติของประเภททรัพยากรลงเสาหลักหนึ่งเสา และความคิดเห็นข้างแต่ละคีย์ระบุกฎที่จัดคีย์นั้นไว้:

  • คุณสมบัติแบบ อ่านกลับ ซึ่งคลาวด์ตั้งค่าและคุณตั้งไม่ได้ ไม่ใช่อินพุต สเกลาร์จะกลายเป็นคีย์ provides ที่ผู้บริโภคอ่านได้
  • ข้อมูลลับ ถูกร่างเป็นการอ้างอิงถึงที่มาของค่า ไม่เป็นค่าเลย ดังที่ ข้อมูลลับ ด้านล่างอธิบาย
  • ตำแหน่งที่วาง คือที่ที่ทรัพยากรอยู่ เช่น location ของ Azure ไปอยู่ใน infra ซึ่งเป็นเสาหลักที่ผู้ดำเนินการจัดหาให้แต่ละสภาพแวดล้อม
  • ตัวตน คือชื่อของทรัพยากรเอง ไปอยู่ใน values ซึ่งเป็นเสาหลักที่นักพัฒนาเขียน
  • คุณสมบัติ อื่นที่จำเป็นทุกรายการ ไปอยู่ใน infra
  • คุณสมบัติ อื่นที่เขียนได้ทุกรายการ ไปอยู่ใต้ infra.overrides ซึ่งเป็นแมปแบบเปิดที่คงการสะกดชื่อแต่ละรายการตามผู้จำหน่าย

สำหรับประเภททรัพยากรนี้ Component อ่านได้ดังนี้:

apiVersion: aggrega.ai/v1beta1
kind: Component
metadata:
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: managed
spec:
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 ความคิดเห็นส่วนหัวของ Recipe ระบุทุกคีย์ที่อ่าน พร้อมกฎและชนิดของแต่ละคีย์ และสิ่งที่ไม่อ่าน:

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 holds

Recipe เขียนทรัพยากรหนึ่งรายการ คือรายการที่ประเภทนั้นระบุ และไม่มีอย่างอื่น ไม่มีกลุ่มทรัพยากร ไม่มีเครือข่าย ไม่มีตัวตนที่คุณไม่ได้ประกาศ ค่า provides แต่ละค่าเป็นนิพจน์ทั้งหมดที่ Azure ประเมินค่าเมื่อเทมเพลตปรับใช้ และส่งผ่านไปยังผู้บริโภคเป็นสตริงตามที่เป็น คีย์ของ infra.overrides ที่ส่วนหัวไม่ได้ระบุจะหยุดการบิลด์โดยระบุชื่อคีย์นั้น การตั้งค่าที่สะกดผิดจึงถูกจับได้ก่อนที่จะปรับใช้สิ่งใด

ตรวจทานทั้งสองไฟล์ก่อนบิลด์ การย้ายการตั้งค่าระหว่างเสาหลักคือการแก้ไข Component และวิธีที่ Recipe อ่านการตั้งค่านั้น และไฟล์เหล่านี้เป็นของคุณ ไม่มีสิ่งที่การบิลด์พึ่งพาเก็บไว้ที่อื่น

ใช้ฉบับร่างใน Aggregate และ Release

การนำเข้าไม่ร่าง Aggregate, Manifest และ Release เลย บรรทัดที่ใช้ Component ที่ร่างไว้จึงเป็นของคุณ ใน Aggregate คือ aggregate.yaml มีส่วนประกอบหนึ่งรายการของชนิดที่ร่างไว้ ซึ่งมีตัวตนที่เสาหลัก values เก็บไว้:

apiVersion: aggrega.ai/v1beta1
kind: Aggregate
metadata:
name: identities
version: 1.0.0
spec:
components:
deploy-identity:
type: imported/security/microsoft-managedidentity-userassignedidentities:0.1.0
values:
name: deploy-identity

ใน Manifest คือ manifest.yaml มีหนึ่งบรรทัดที่บอกว่า Recipe ใดทำให้ประเภทนั้นเป็นจริง:

apiVersion: aggrega.ai/v1beta1
kind: Manifest
metadata:
name: identities
version: 1.0.0
spec:
mappings:
components:
type:
imported/security/microsoft-managedidentity-userassignedidentities:0.1.0: arm/microsoft-managedidentity-userassignedidentities:0.1.0

ใน Release คือ release.yaml มีแนวเขตที่ส่วนประกอบไปอยู่ และเสาหลัก infra ที่ Recipe ต้องการ คือตำแหน่งที่วาง:

apiVersion: aggrega.ai/v1beta1
kind: Release
metadata:
name: identities
version: 1.0.0
environment: production
spec:
aggregate: ./aggregate.yaml
manifest: ./manifest.yaml
boundaries:
azure:
directory: azure
components:
deploy-identity:
infra:
location: westeurope

ตรวจสอบความถูกต้องและบิลด์

Terminal window
aggrega validate --release release.yaml
release dependency validation passed: release.yaml (schema-pillar + dependency pillars)

pull สิ่งที่ Release พึ่งพา แล้วบิลด์:

Terminal window
aggrega pull --release release.yaml
aggrega build --release release.yaml
Pull 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 โดยมีทรัพยากรหนึ่งรายการ ภายใต้ชื่อสัญลักษณ์ที่อินสแตนซ์ตั้งให้ นอกจากสมาชิกของทรัพยากรเองแล้ว การบิลด์บันทึกว่า Aggregate, Release และ Recipe ใดสร้างทรัพยากรนั้นไว้ใต้ metadata:

{
"$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 Provider อธิบายคำสั่งที่ปรับใช้เทมเพลตที่ขอบเขตกลุ่มทรัพยากร ประเภททรัพยากรที่เขียนได้เฉพาะที่ขอบเขต subscription หรือขอบเขต management group จะถูกร่างเป็นส่วนย่อยสำหรับขอบเขตนั้น และเฮดเดอร์ของ Recipe ระบุคำอธิบายประกอบแนวเขตที่ Release ตั้ง ดังที่ การปรับใช้ที่ขอบเขต subscription และ การปรับใช้ที่ขอบเขต management group อธิบาย ประเภทที่เขียนได้เฉพาะที่ขอบเขตผู้เช่า หรือเฉพาะในฐานะส่วนขยายของทรัพยากรอื่น จะถูกปฏิเสธโดยระบุชื่อ

ข้อมูลลับ

ค่าของคุณสมบัติที่เป็นข้อมูลลับไม่ถูกเขียนลงในฉบับร่างเลย และไม่มีการร่างค่าเริ่มต้นให้ วิธีที่ค่าไปถึงทรัพยากรขึ้นอยู่กับผู้ให้บริการ:

  • Azure: พารามิเตอร์ securestring ระดับบนสุดของเทมเพลต ตั้งชื่อตามอินสแตนซ์และคุณสมบัติ ซึ่งคุณจัดหาให้เมื่อปรับใช้ ข้อมูลลับที่ผู้จำหน่ายทำเครื่องหมายว่าไม่บังคับจะเป็นพารามิเตอร์ที่จำเป็น
  • CloudFormation: รายการ Parameters ของเทมเพลตที่ทำเครื่องหมาย NoEcho ตั้งชื่อด้วยวิธีเดียวกัน ข้อมูลลับที่ผู้จำหน่ายทำเครื่องหมายว่าไม่บังคับจะเป็นพารามิเตอร์ที่จำเป็น
  • Terraform: สล็อต Feature บน Component และตัวแปรโมดูลที่ทำเครื่องหมาย sensitive: true ค่ามาจากข้อมูลลับที่ Release แนบกับสล็อต

เฉพาะคุณสมบัติที่ระดับบนสุดของทรัพยากรเท่านั้นที่กลายเป็นข้อมูลลับ — บน Azure คือคีย์รูท หรือสมาชิกของ properties สมาชิกที่ละเอียดอ่อนซึ่งอยู่ต่ำกว่านั้น เช่น adminPassword ภายใน osProfile ของ Azure หรือ password ภายในบล็อก Terraform จะไม่ถูกร่างเป็นข้อมูลลับ Release ตั้งค่าเป็นค่าธรรมดาภายในคีย์ที่ระดับบนของสมาชิกนั้นถูกร่างไว้ และการนำเข้าเตือนทุกรายการภายใต้ constraint-dropped โดยระบุเส้นทางและคีย์นั้น

คุณสมบัติของ CloudFormation ถูกอ่านเป็นข้อมูลลับเมื่อชื่อมีคำที่เกี่ยวกับข้อมูลรับรอง — รหัสผ่าน ข้อมูลลับ โทเค็น ข้อมูลรับรอง คีย์ส่วนตัว คีย์ API หรือวลีรหัสผ่าน — และไม่ลงท้ายด้วย Arn, Id, Name หรือ Ref การอ่านเช่นนั้นเป็นธรรมเนียมของฉบับร่าง และส่วนหัวของ Recipe ทำเครื่องหมายทุกคุณสมบัติที่อ่านเป็นข้อมูลลับ คุณจึงยืนยันคุณสมบัติเหล่านั้นในการตรวจทาน

การนำเข้าเดียวกันบน CloudFormation และ Terraform

ขั้นตอนเหมือนกัน ต่างกันเพียงการส่งออกและรูปทรงของ Recipe สองกรณีด้านล่างร่างจากสคีมาสังเคราะห์ ซึ่งข้อความของผู้จำหน่ายถูกตัดออกจากสิ่งที่ตามมา

CloudFormation

Terminal window
aws cloudformation describe-type --type RESOURCE --type-name AWS::Example::Ledger > ledger.json
aggrega import ledger.json

การนำเข้าเขียน Component และ Recipe และคำเตือนหนึ่งรายการสำหรับข้อจำกัดของผู้จำหน่ายแต่ละข้อที่นำมาด้วยไม่ได้:

wrote catalog/component/imported/component/aws-example-ledger/0.1.0/component.yaml
wrote catalog/recipe/cloudformation/aws-example-ledger/0.1.0/recipe.yaml
wrote .aggrega-import.json
read 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 object
mapped AWS::Example::Ledger (AWS::Example::Ledger) to imported/component/aws-example-ledger as a draft, NONE at 0.0167

template.yaml ของ Recipe ประกาศทรัพยากรภายใต้ตัวระบุเชิงตรรกะที่อินสแตนซ์ตั้งให้ โดยข้อมูลลับเป็นพารามิเตอร์ 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 }}.Arn

Terraform

Terminal window
terraform init && terraform providers schema -json > schema.json
aggrega import schema.json
wrote catalog/component/imported/component/aws-example-ledger/0.1.0/component.yaml
wrote catalog/recipe/terraform/aws-example-ledger/0.1.0/recipe.yaml
wrote catalog/recipe/terraform/aws-example-ledger/0.1.0/module/main.tf.json
wrote .aggrega-import.json

การส่งออก Terraform ระบุชื่อผู้ให้บริการที่การกำหนดค่าต้องการแต่ไม่ระบุเวอร์ชัน การนำเข้าจึงเตือน:

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 Recipe

ฉบับร่าง Terraform คือ Recipe ที่มีโมดูลอยู่ข้างกัน module/main.tf.json ประกาศตัวแปรหนึ่งตัวสำหรับแต่ละอินพุต ทรัพยากรหนึ่งรายการคือ this โดยแต่ละอาร์กิวเมนต์อ่านจากตัวแปรของตน และผู้ให้บริการที่การส่งออกระบุ spec.source ของ Recipe ชี้ไปที่โมดูล และ valuesMapping เติมแต่ละตัวแปรจากเสาหลักของ Component โดยเขียนอินพุตที่ไม่บังคับเฉพาะที่ Release ตั้งค่า ปักหมุดโมดูลก่อน pull ครั้งแรก เพื่อให้ล็อกบันทึกไดเจสต์ของโมดูล:

Terminal window
aggrega pin catalog/recipe/terraform/aws-example-ledger/0.1.0/recipe.yaml
Pinned 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 ที่ยังไม่ปักหมุดจะหยุด pull โดยระบุ aggrega pin ให้ปักหมุดอีกครั้งหลังการแก้ไขโมดูลแต่ละครั้ง

บรรทัดของ Aggregate, Manifest และ Release เหมือนกับกรณี Azure โดยใช้ชื่อที่ร่างไว้และ infra ของผู้ให้บริการเอง Release ของ Terraform ระบุคีย์ตำแหน่งที่วางของผู้ให้บริการ เช่น 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/identity

Recipe ใช้ชื่อ identity-microsoft-managedidentity-userassignedidentities ตาม Component จึงไม่ใช้ชื่อของ 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.tenantId

Azure ซ้อนแอตทริบิวต์นี้ไว้ใต้ properties บรรทัดที่ต้องเขียนจึงเป็นบรรทัดที่ฉบับร่างเต็มของประเภทนั้นมี:

provides:
principal_id: "[reference('{{ .locals.symbol }}').principalId]"

เมื่อเขียนบรรทัดนั้นแล้ว Release ระบุ Component ใน Aggregate และ Recipe ใน Manifest ตามข้างต้น ตั้งตำแหน่งที่วางภายใต้ infra.overrides.location และตรวจสอบความถูกต้องและบิลด์ได้เทมเพลตเดียวกัน

ชื่อที่แค็ตตาล็อกไม่มี Component ของชื่อนั้นจะถูกร่างเป็น Component ใหม่ภายใต้ชื่อนั้น และการนำเข้าเตือน ชื่อที่พิมพ์ Component ผิดจึงไม่ถูกเข้าใจผิดว่าเป็นชื่อใหม่

ขั้นต่อไป

  • ตัวนำเข้าแกน อธิบายสิ่งที่ตัวนำเข้าแต่ละตัวอ่าน วิธีเลือกระหว่างหลายประเภทและระหว่างผู้ให้บริการหลายราย การแบ่งโดยสมบูรณ์ สิ่งที่แต่ละเป้าหมายร่าง และการวินิจฉัยที่ทั้งสามตัวรายงาน
  • ผู้ให้บริการ arm อธิบายเทมเพลตที่ฉบับร่าง Azure ถูกรวมเข้าไปและขอบเขตที่ปรับใช้
  • aggrega import คือเอกสารอ้างอิงฉบับเต็มของคำสั่ง