1. Answers
  2. Creating a GCP Redis instance with Pulumi

How do I create a GCP Redis instance with Pulumi?

In this guide, we will create a Redis instance on Google Cloud using Pulumi. Redis is an in-memory data structure store used as a database, cache, and message broker. We will use the gcp.redis.Instance resource from the Pulumi GCP provider to set up the Redis instance.

Key Points

  • We will define a Redis instance with specific configurations such as name, region, memory size, and tier.
  • We will use the gcp.redis.Instance resource to manage the Redis instance on Google Cloud.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

// Create a GCP Redis instance
const redisInstance = new gcp.redis.Instance("my-redis-instance", {
    name: "my-redis-instance",
    region: "us-central1",
    tier: "STANDARD_HA",
    memorySizeGb: 1,
    redisVersion: "REDIS_6_X",
    alternativeLocationId: "us-central1-f",
    authorizedNetwork: "default",
    displayName: "My Redis Instance",
    locationId: "us-central1-a",
    replicaCount: 2,
    reservedIpRange: "10.0.0.0/29",
    redisConfigs: {
        "maxmemory-policy": "allkeys-lru",
    },
});

// Export the Redis instance details
export const redisInstanceName = redisInstance.name;
export const redisInstanceHost = redisInstance.host;
export const redisInstancePort = redisInstance.port;

Summary

In this guide, we created a Redis instance on Google Cloud using Pulumi. We defined the instance with specific properties such as name, region, memory size, and tier. We used the gcp.redis.Instance resource to manage the Redis instance and exported the instance details such as name, host, and port.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up