JSON => YAML Converter

JSON to YAML Conversion Example

JSON (Example 1)
{
  "_index": "searchasservice-configure-resources-v1",
  "_type": "_doc",
  "_id": "test-templemanager-users-v1-en",
  "_score": 1,
  "_source": {
    "resourceMetadata": {
      "domain": "templemanager",
      "name": "users",
      "version": "v1",
      "language": "en"
    },
    "schema": {},
    "id": "test-templemanager-users-v1-en"
  }
}
Converted YAML (Example 1)
_index: "searchasservice-configure-resources-v1"
_type: "_doc"
_id: "test-templemanager-users-v1-en"
_score: 1
_source:
  resourceMetadata:
    domain: "templemanager"
    name: "users"
    version: "v1"
    language: "en"
  schema: {}
  id: "test-templemanager-users-v1-en"

JSON (Example 2)
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Creates an SQS queue with AWS CloudWatch alarms on queue depth ",
  "Parameters": {
    "FailureNotificationEmail": {
      "Description": "Email address where it is configured to send failure notification",
      "Type": "String",
      "AllowedPattern": "([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)",
      "ConstraintDescription": "The email address must be a valid one"
    }
  },
  "Resources": {
    "ImageTransformationServiceQueue": {
      "Type": "AWS::SQS::Queue",
      "Properties": {}
    },
    "FailureNotificationTopic": {
      "Type": "AWS::SNS::Topic",
      "Properties": {
        "Subscription": [
          {
            "Endpoint": {
              "Ref": "FailureNotificationEmail"
            },
            "Protocol": "email"
          }
        ]
      }
    },
    "QueueDepthAlarm": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "AlarmDescription": "Alarms if queue depth grows beyond 25000 messages",
        "Namespace": "AWS/SQS",
        "MetricName": "ApproximateNumberOfMessagesVisible",
        "Dimensions": [
          {
            "Name": "QueueName",
            "Value": {
              "Fn::GetAtt": [
                "ImageTransformationServiceQueue",
                "QueueName"
              ]
            }
          }
        ],
        "Statistic": "Sum",
        "Period": "300",
        "EvaluationPeriods": "1",
        "Threshold": "25000",
        "ComparisonOperator": "GreaterThanThreshold",
        "AlarmActions": [
          {
            "Ref": "FailureNotificationTopic"
          }
        ],
        "InsufficientDataActions": [
          {
            "Ref": "FailureNotificationTopic"
          }
        ]
      }
    }
  },
  "Outputs": {
    "QueueURL": {
      "Description": "URL of the ImageTransformationServiceQueue",
      "Value": {
        "Ref": "ImageTransformationServiceQueue"
      }
    },
    "QueueARN": {
      "Description": "ARN of the ImageTransformationServiceQueue",
      "Value": {
        "Fn::GetAtt": [
          "ImageTransformationServiceQueue",
          "Arn"
        ]
      }
    },
    "QueueName": {
      "Description": "Name of the ImageTransformationServiceQueue",
      "Value": {
        "Fn::GetAtt": [
          "ImageTransformationServiceQueue",
          "QueueName"
        ]
      }
    }
  }
}
Converted YAML (Example 2)
AWSTemplateFormatVersion: "2010-09-09"
Description: "Creates an SQS queue with AWS CloudWatch alarms on queue depth "
Parameters:
  FailureNotificationEmail:
    Description: "Email address where it is configured to send failure notification"
    Type: "String"
    AllowedPattern: "([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)"
    ConstraintDescription: "The email address must be a valid one"
Resources:
  ImageTransformationServiceQueue:
    Type: "AWS::SQS::Queue"
    Properties: {}
  FailureNotificationTopic:
    Type: "AWS::SNS::Topic"
    Properties:
      Subscription:
        - Endpoint:
            Ref: "FailureNotificationEmail"
          Protocol: "email"
  QueueDepthAlarm:
    Type: "AWS::CloudWatch::Alarm"
    Properties:
      AlarmDescription: "Alarms if queue depth grows beyond 25000 messages"
      Namespace: "AWS/SQS"
      MetricName: "ApproximateNumberOfMessagesVisible"
      Dimensions:
        - Name: "QueueName"
          Value:
            Fn::GetAtt:
              - "ImageTransformationServiceQueue"
              - "QueueName"
      Statistic: "Sum"
      Period: "300"
      EvaluationPeriods: "1"
      Threshold: "25000"
      ComparisonOperator: "GreaterThanThreshold"
      AlarmActions:
        - Ref: "FailureNotificationTopic"
      InsufficientDataActions:
        - Ref: "FailureNotificationTopic"
Outputs:
  QueueURL:
    Description: "URL of the ImageTransformationServiceQueue"
    Value:
      Ref: "ImageTransformationServiceQueue"
  QueueARN:
    Description: "ARN of the ImageTransformationServiceQueue"
    Value:
      Fn::GetAtt:
        - "ImageTransformationServiceQueue"
        - "Arn"
  QueueName:
    Description: "Name of the ImageTransformationServiceQueue"
    Value:
      Fn::GetAtt:
        - "ImageTransformationServiceQueue"
        - "QueueName"

Copyright © Karigar's Input/Output Tools 2024.