This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from jhernand/add_ccs_cluster_example
Add CCS cluster example
- Loading branch information
Showing
4 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# _CCS_ cluster creation example | ||
|
||
This example shows how to create a _CCS_ cluster. _CCS_ stands for _costumer | ||
cloud subscription_ and is a cluster that is created in the cloud | ||
infrastructure (AWS account or GCP project, for example) provided by the user. | ||
|
||
In order to create a _CCS_ cluster it is necessary to have user named | ||
`osdCcsAdmin` with the `AdministratorAccess`. The example uses the `aws` | ||
provider to create that user and attach the role. To do so it uses the | ||
credentials of the current user, typically taken from the `~/.aws/credentials` | ||
file. See the documentation of the `aws` provider for details. | ||
|
||
Once the `osdCcsAdmin` user is created the example uses the `aws` provider | ||
again to generate an access key and secret for that user. That key and secret | ||
are then be used to create the cluster. | ||
|
||
To run it use adjust the description of the provider and the cluster in the | ||
`main.tf` and then run the `terraform apply` command. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright (c) 2021 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 3.67" | ||
} | ||
ocm = { | ||
version = ">= 0.1" | ||
source = "openshift-online/ocm" | ||
} | ||
} | ||
} | ||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
provider "ocm" { | ||
} | ||
|
||
data "aws_caller_identity" "current" { | ||
} | ||
|
||
resource "aws_iam_user" "admin" { | ||
name = "osdCcsAdmin" | ||
} | ||
|
||
resource "aws_iam_user_policy_attachment" "admin_access" { | ||
user = aws_iam_user.admin.name | ||
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" | ||
} | ||
|
||
resource "aws_iam_access_key" "admin_key" { | ||
user = aws_iam_user.admin.name | ||
} | ||
|
||
resource "ocm_cluster" "my_cluster" { | ||
name = "my-cluster" | ||
cloud_provider = "aws" | ||
cloud_region = "us-east-1" | ||
ccs_enabled = true | ||
aws_account_id = data.aws_caller_identity.current.account_id | ||
aws_access_key_id = aws_iam_access_key.admin_key.id | ||
aws_secret_access_key = aws_iam_access_key.admin_key.secret | ||
} |
File renamed without changes.
File renamed without changes.