This repository was archived by the owner on Jan 17, 2025. It is now read-only.
Manage datashare consumer permissions to use datashares#20
Merged
winglot merged 1 commit intobrainly:masterfrom Aug 20, 2021
Merged
Manage datashare consumer permissions to use datashares#20winglot merged 1 commit intobrainly:masterfrom
winglot merged 1 commit intobrainly:masterfrom
Conversation
677ff35 to
61b777e
Compare
…e to consumer clusters
61b777e to
0a8895d
Compare
Contributor
Author
|
here is the terraform template for the end-to-end test case. You will need to populate the variables accordingly. # Variables for provider configuration
variable "producer_cluster_host" {
type = string
}
variable "producer_cluster_port" {
type = number
}
variable "producer_cluster_database" {
type = string
}
variable "consumer_cluster_host" {
type = string
}
variable "consumer_cluster_port" {
type = number
}
variable "consumer_cluster_database" {
type = string
}
terraform {
required_providers {
redshift = {
# version info is omitted as this is a local build using provider development overrides
# see https://www.terraform.io/docs/cli/config/config-file.html#development-overrides-for-provider-developers
source = "brainly/redshift"
}
}
}
# Set up provider aliases for producer and consumer cluster
provider "redshift" {
alias = "producer"
host = var.producer_cluster_host
port = var.producer_cluster_port
database = var.producer_cluster_database
}
provider "redshift" {
alias = "consumer"
host = var.consumer_cluster_host
port = var.consumer_cluster_port
database = var.consumer_cluster_database
}
# Variables for resource configuration
variable "internal_schemas" {
type = list(string)
}
variable "datashare_name" {
type = string
}
variable "datashare_db_name" {
type = string
}
# Define all of the internal schemas on the producer cluster
resource "redshift_schema" "producer_internal_schemas" {
provider = redshift.producer
for_each = toset(var.internal_schemas)
name = each.key
}
# Define the datashare on the producer cluster,
# and add all internal schemas to it
resource "redshift_datashare" "producer_share" {
provider = redshift.producer
name = var.datashare_name
schemas = [for s in redshift_schema.producer_internal_schemas : s.name]
}
data "redshift_namespace" "consumer" {
provider = redshift.consumer
}
# Ensure the consumer cluster has permission to access the data share.
resource "redshift_datashare_privilege" "consumer" {
provider = redshift.producer
share_name = redshift_datashare.producer_share.name
namespace = data.redshift_namespace.consumer.id
}
# Create an external database from the datashare
resource "redshift_database" "consumer_share" {
provider = redshift.consumer
name = var.datashare_db_name
datashare_source {
share_name = redshift_datashare.producer_share.name
namespace = redshift_datashare.producer_share.producer_namespace
}
depends_on = [
redshift_datashare_privilege.consumer
]
}
# Create external schemas from the datashare on the consumer cluster
resource "redshift_schema" "consumer_share_schemas" {
for_each = toset(redshift_datashare.producer_share.schemas)
provider = redshift.consumer
name = each.key
external_schema {
database_name = redshift_database.consumer_share.name
redshift_source {
schema = each.key
}
}
} |
winglot
approved these changes
Aug 20, 2021
StevenKGER
referenced
this pull request
in dbsystel/terraform-provider-redshift
Oct 25, 2024
…-go-v2-credentials-1.x Update module github.com/aws/aws-sdk-go-v2/credentials to v1.13.41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: this PR builds off of (and thus includes the changes in) #18.Adds a
redshift_datashare_privilegeresource which is used to grant usage permissions to consumer clusters and destination accounts. As with other datasharing related changes, this functionality only works on RA3 clusters.For permissions in the same account:
For permissions across accounts:
Notes on cross-account data sharing:
Test cases are conditionally enabled on environment variables:
REDSHIFT_DATASHARE_SUPPORTED- must be non-empty to enable either testREDSHIFT_DATASHARE_CONSUMER_NAMESPACE- must be a valid cluster namespace guid to enable the test for sharing within the same accountREDSHIFT_DATASUARE_CONSUMER_ACCOUNT- must be a valid AWS account ID to enable the test for sharing across accounts.The test case for data sharing within the same AWS account passes, and using a local build from this PR, I am able to successfully run a manual end-to-end test case of data sharing between two RA3 clusters in the same account.