Skip to content

Commit d7bd6d8

Browse files
committed
Initial commit
0 parents  commit d7bd6d8

File tree

12 files changed

+454
-0
lines changed

12 files changed

+454
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Prevent accidental commit of service accounts or service principals
2+
*.json

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Rubrik
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Terraform Provider Polaris Examples
2+
3+
This repository contains examples of how to use the [Polaris](https://registry.terraform.io/providers/rubrikinc/polaris/latest) provider with [Terraform](https://www.terraform.io/).

aws/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to the Polaris service account file."
14+
}
15+
16+
variable "profile" {
17+
type = string
18+
description = "AWS profile."
19+
}
20+
21+
# Point the provider to the Polaris service account to use.
22+
provider "polaris" {
23+
credentials = var.polaris_credentials
24+
}
25+
26+
# Add the AWS account to Polaris. Access key and secret key are read from
27+
# ~/.aws/credentials. The default region is read from ~/.aws/config. Polaris
28+
# will authenticate to AWS using an IAM role setup in a CloudFormation stack.
29+
resource "polaris_aws_account" "default" {
30+
profile = var.profile
31+
32+
regions = [
33+
"us-east-2",
34+
]
35+
}

aws_exocompute/main.tf

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to the Polaris service account file."
14+
}
15+
16+
variable "profile" {
17+
type = string
18+
description = "AWS profile."
19+
}
20+
21+
variable "vpc_id" {
22+
type = string
23+
description = "AWS VPC ID."
24+
}
25+
26+
variable "subnet1" {
27+
type = string
28+
description = "AWS subnet 1."
29+
}
30+
31+
variable "subnet2" {
32+
type = string
33+
description = "AWS subnet 2."
34+
}
35+
36+
# Point the provider to the Polaris service account to use.
37+
provider "polaris" {
38+
credentials = var.polaris_credentials
39+
}
40+
41+
# Add the AWS account to Polaris.
42+
resource "polaris_aws_account" "default" {
43+
profile = var.profile
44+
45+
regions = [
46+
"us-east-2",
47+
]
48+
49+
exocompute {
50+
regions = [
51+
"us-east-2",
52+
]
53+
}
54+
}
55+
56+
# Create an excompute configuration using the specified VPC and subnets.
57+
resource "polaris_aws_exocompute" "default" {
58+
account_id = polaris_aws_account.default.id
59+
region = "us-east-2"
60+
vpc_id = var.vpc_id
61+
62+
subnets = [
63+
var.subnet1,
64+
var.subnet2,
65+
]
66+
}

azure/main.tf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to Polaris service account file."
14+
}
15+
16+
variable "azure_credentials" {
17+
type = string
18+
description = "Path to the Azure service principal file."
19+
}
20+
21+
variable "subscription_id" {
22+
type = string
23+
description = "Azure subscription id."
24+
}
25+
26+
variable "subscription_name" {
27+
type = string
28+
description = "Azure subscription name."
29+
}
30+
31+
variable "tenant_domain" {
32+
type = string
33+
description = "Azure tenant domain."
34+
}
35+
36+
# Point the provider to the Polaris service account to use.
37+
provider "polaris" {
38+
credentials = var.polaris_credentials
39+
}
40+
41+
# Add the Azure service principal to Polaris. See the main README for an
42+
# explanation of this file.
43+
resource "polaris_azure_service_principal" "default" {
44+
credentials = var.azure_credentials
45+
}
46+
47+
# Add the Azure subscription to Polaris. This resource depends on the service
48+
# principal resource.
49+
resource "polaris_azure_subscription" "default" {
50+
subscription_id = var.subscription_id
51+
subscription_name = var.subscription_name
52+
tenant_domain = var.tenant_domain
53+
54+
regions = [
55+
"eastus2"
56+
]
57+
58+
depends_on = [
59+
polaris_azure_service_principal.default
60+
]
61+
}

azure_exocompute/main.tf

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to Polaris service account file."
14+
}
15+
16+
variable "azure_credentials" {
17+
type = string
18+
description = "Path to the Azure service principal file."
19+
}
20+
21+
variable "subscription_id" {
22+
type = string
23+
description = "Azure subscription id."
24+
}
25+
26+
variable "subscription_name" {
27+
type = string
28+
description = "Azure subscription name."
29+
}
30+
31+
variable "tenant_domain" {
32+
type = string
33+
description = "Azure tenant domain."
34+
}
35+
36+
variable "subnet" {
37+
type = string
38+
description = "Azure subnet."
39+
}
40+
41+
# Point the provider to the Polaris service account to use.
42+
provider "polaris" {
43+
credentials = var.polaris_credentials
44+
}
45+
46+
# Add the Azure service principal to Polaris. See the main README for an
47+
# explanation of this file.
48+
resource "polaris_azure_service_principal" "default" {
49+
credentials = var.azure_credentials
50+
}
51+
52+
# Add the Azure subscription to Polaris.
53+
resource "polaris_azure_subscription" "default" {
54+
subscription_id = var.subscription_id
55+
subscription_name = var.subscription_name
56+
tenant_domain = var.tenant_domain
57+
58+
regions = [
59+
"eastus2",
60+
]
61+
62+
exocompute {
63+
regions = [
64+
"eastus2",
65+
]
66+
}
67+
68+
depends_on = [
69+
polaris_azure_service_principal.default
70+
]
71+
}
72+
73+
# Create an excompute configuration using the specified subnet.
74+
resource "polaris_azure_exocompute" "default" {
75+
subscription_id = polaris_azure_subscription.default.id
76+
region = "eastus2"
77+
subnet = var.subnet
78+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to Polaris service account file."
14+
}
15+
16+
variable "subscription_id" {
17+
type = string
18+
description = "Azure subscription id."
19+
}
20+
21+
variable "subscription_name" {
22+
type = string
23+
description = "Azure subscription name."
24+
}
25+
26+
variable "tenant_domain" {
27+
type = string
28+
description = "Azure tenant domain."
29+
}
30+
31+
# Point the provider to the Polaris service account to use.
32+
provider "polaris" {
33+
credentials = var.polaris_credentials
34+
}
35+
36+
# Add the Azure subscription to Polaris. This resource depends on the service
37+
# principal resource.
38+
resource "polaris_azure_subscription" "default" {
39+
subscription_id = var.subscription_id
40+
subscription_name = var.subscription_name
41+
tenant_domain = var.tenant_domain
42+
43+
regions = [
44+
"eastus2"
45+
]
46+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to Polaris service account file."
14+
}
15+
16+
variable "azure_credentials" {
17+
type = string
18+
description = "Path to the Azure service principal file."
19+
}
20+
21+
# Point the provider to the Polaris service account to use.
22+
provider "polaris" {
23+
credentials = var.polaris_credentials
24+
}
25+
26+
# Add the Azure service principal to Polaris. See the main README for an
27+
# explanation of this file.
28+
resource "polaris_azure_service_principal" "default" {
29+
credentials = var.azure_credentials
30+
}

gcp/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Point Terraform to the Polaris provider.
2+
terraform {
3+
required_providers {
4+
polaris = {
5+
source = "rubrikinc/polaris"
6+
version = "~>0.2.0"
7+
}
8+
}
9+
}
10+
11+
variable "polaris_credentials" {
12+
type = string
13+
description = "Account name or path to the Polaris service account file."
14+
}
15+
16+
variable "gcp_credentials" {
17+
type = string
18+
description = "Path to the GCP service account key file."
19+
}
20+
21+
variable "project" {
22+
type = string
23+
description = "GCP project id."
24+
}
25+
26+
# Point the provider to the Polaris service account to use.
27+
provider "polaris" {
28+
credentials = var.polaris_credentials
29+
}
30+
31+
# Add the GCP project to Polaris.
32+
resource "polaris_gcp_project" "default" {
33+
credentials = var.gcp_credentials
34+
project = var.project
35+
}

0 commit comments

Comments
 (0)