npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amplience-graphql-codegen-terraform

v1.2.1

Published

This is a plugin for GraphQL Codegen that outputs your schema to Amplience resources in Terraform.

Downloads

3,262

Readme

amplience-graphql-codegen-terraform

This is a plugin for GraphQL Codegen that outputs your schema to Amplience resources in Terraform.

It will look for types with an @amplienceContentType directive and generate Terraform resources that create Amplience Content Types. This terraform code is dependent on the Amplience Terraform provider.

Furthermore, this plugin requires amplience-graphql-codegen-json to generate the necessary JSON files the terraform code refers to.

For an example output see the example output terraform file.

For more information on the Amplience Terraform provider, see the documentation on the terraform registry.

codegen.yml

A basic example:

overwrite: true
schema: ./schema.graphql
hooks:
  afterAllFileWrite:
    - terraform fmt
generates:
  terraform/amplience_content_types.tf:
    plugins:
      - amplience-graphql-codegen-terraform
    config:
      hostname: "https://schema-examples.com"
      visualization:
        - label: Localhost with layout
          templated_uri: https://example.com/preview?vse={{vse.domain}}&content={{content.sys.id}}
          default: false
      content_repositories:
        website1: var.variables["CONTENT_REPO1_ID"] # A terraform variable.
        website2: 1234567890123456789 # A direct content repo id value.
        website3: ${WEBSITE_3} # A environment variable.
      slot_repositories:
        slot1: var.variables["SLOT_REPO1_ID"]
        slot2: var.variables["SLOT_REPO2_ID"]
      add_required_provider: true # defaulted to true, will generate required_providers block, removed otherwise

The hostname is optional and will default to https://schema-examples.com. This is a prefix that is used to define the JSON schema resources and should be a URL. The visualization is also optional.

The values for the visualization, the content_repositories, and the slot_repositories can either be a direct value, an environment variable using the ${MY_VAR} syntax, or a reference to a terraform variable.

Your Graphql file

Basic example:

type MyContentType @amplienceContentType {
    ...
}

By default this will generate Terraform resources for a content type named "my-content-type". It will be assigned to the first repository (e.g. website1).

You can change the repository and its validationLevel by specifying those as arguments. Please note that if you use a SLOT validation level, you should refer to one within the slot_repositories or otherwise it will default to the first slot repository. You can also enable visualizations for this type by setting that argument to true.

Optionally, you can also add @icon(url: 'some-test-url'). This will add icon support for the Amplience content-type

Additionally, you can also add autoSync into the directive. This is an optional directive that accepts boolean (defaulted to true). This will allow autoSync to be in place. Note that this only available from Amplience Terraform Provider version >= 0.4.0

A full example you can see below:

type MyContentType @amplienceContentType(
    repository: "slot2", # To overwrite the default repository (first)
    kind: SLOT, # Can either be CONTENT_TYPE (default), SLOT, or HIERARCHY
    visualizations: true, # If true, it will add the visualizations defined in the codegen.yml
    icon: "http://example.com/icon.png"
    autoSync: true # Optional field, defaulted to `true` if not specified, and it will allow content-type to be sync-ed automatically
) {
    ...
}

Note that partials are not supported. Instead you could just inline all the partials using amplience-graphql-codegen-json.