如果要从代码源代码块中获取connection_resource_type = "*“,则包含一个源代码= connection_resource_type = "cosmosdb-SQL"
Main.tf
module "network-security-group" {
source = "git@github.com:test/terraform-azure-network-security-group.git?ref=v3.1.1"
subscription_id = var.subscription_id
resource_group = var.resource_group
resource_name = local.nsg_name
security_rules = var.security_rules
context = var.context
}
module "tf_azure_private_endpoint_sean125" {
source = "git@github.com:***/terraform-azure-utils.git//private-endpoint?ref=***"
subscription_id = "ed6d71e6-0262-49ad-b8ff-074000058889"
depends_on = []
connection_resource_type = "cosmosdb-SQL"
resource_name = ""
pgi_private_endpoint_enabled = "false"
enable_private_endpoint = "false"
connection_resource_id = "wefew"
resource_group = "AZ-RG-Sean-Demo-01"
resource_tags = {
Application_Id = "CI002489694"
Application_Name = "Demo"
Billing_Notification_Group = ""
Cost_Center = "1076015162"
Original_Requestor = "***"
Owner_Notification_Group = ""
Owning_Role = null
Security_Notification_Group = ""
Stage = "Dev"
Technical_Notification_Group = ""
WBS_Element = null
terraform_managed = "true"
}bashscript.sh
#!/bin/bash
arr=()
a=`cat main.tf`
for i in $a
do
az=$(sed 's/^[^{]*{\([^{}]*\)}.*/\1/' main.tf)
if [[ $i == "key-vault = true"]]
then
echo $i
if [[ $line == *"key-vault = true"* ]]
then
echo $line
az=$(sed 's/^[^{]*{\([^{}]*\)}.*/\1/' main.tf)
fi
done发布于 2022-12-01 08:17:19
cat main.tf | sed 's/^}$/||/' | tr '\n' ' ' | sed 's/||/}\n/g' | grep -Eo 'source\s+=\s+.*key-vault\s+=\s+true' | grep -Eo 'source\s+=\s+"[[:alnum:][:punct:]]+"\s'https://stackoverflow.com/questions/74638206
复制相似问题