Code Monkey home page Code Monkey logo

sceptre-json-resolver's Introduction

sceptre-json-resolver

A Sceptre resolver to serialize and deserialize json.

Motivation

There are use cases where you may want to pass in either a string or a json object to a cloudformation or sceptre_user_data parameter. This simple resolver can take some json and serialize it or deserialize it before passing it into a cloudformation parameter or a scepter_user_data parameter.

Installation

To install directly from PyPI

pip install sceptre-json-resolver

To install from this git repo

pip install git+https://github.com/Sceptre/sceptre-json-resolver.git

Usage/Examples

parameters|sceptre_user_data:
  <name>: !from_json [ <string> ]

parameters|sceptre_user_data:
  <name>: !to_json [ <json object> ]

NOTE: This resolver expects a single-item list argument.

Basic Examples

Take some json object serialize it to a string then pass it to a parameter:

parameters:
   myparam: !to_json [{"key": "value"}]

Note: The string '{"key": "value"}' is passed to myparam

Take a string deserialize it to a json object then pass it to a parameter:

sceptre_user_data:
  myparam: !from_json ['{"key": "value"}']

Note: The object {"key": "value"} is passed to myparam

Nested resolver examples

These use case requires the nested resolver feature in Sceptre version 4.1 and greater.

Load a json object from a file using the sceptre file resolver, serialize the object to a string then pass it to a parameter:

parameters:
  hounds: !to_json [ !file 'hounds.json' ]

Make a request to a REST API using the sceptre-request-resolver, deserialize the response to a json object then pass it to a parameter:

sceptre_user_data:
  hounds: !from_json
    - !request 'https://dog.ceo/api/breed/hound/list'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.