Skip to content

Commit

Permalink
Merge pull request #5695 from ameukam/kops-eks-cluster
Browse files Browse the repository at this point in the history
AWS: setup config for kOps CI
  • Loading branch information
k8s-ci-robot authored Aug 8, 2023
2 parents 2a195ef + fdb6862 commit d2ba573
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
30 changes: 30 additions & 0 deletions infra/aws/terraform/kops-infra-ci/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2023 The Kubernetes Authors.
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.
*/

data "aws_availability_zones" "available" {
provider = aws.kops-infra-ci
state = "available"
}

data "aws_caller_identity" "current" {
provider = aws.kops-infra-ci
}

data "aws_region" "current" {
provider = aws.kops-infra-ci
}

data "aws_organizations_organization" "current" {}
22 changes: 22 additions & 0 deletions infra/aws/terraform/kops-infra-ci/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2023 The Kubernetes Authors.
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.
*/


locals {
kops-infra-ci-name = "kops-infra-ci"
kops-infra-ci-index = index(data.aws_organizations_organization.current.accounts.*.name, local.kops-infra-ci-name)
kops-infra-ci-account-id = data.aws_organizations_organization.current.accounts[local.kops-infra-ci-index].id
}
24 changes: 24 additions & 0 deletions infra/aws/terraform/kops-infra-ci/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2023 The Kubernetes Authors.
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.
*/

provider "aws" {
region = "us-east-2"
alias = "kops-infra-ci"

assume_role {
role_arn = "arn:aws:iam::${local.kops-infra-ci-account-id}:role/OrganizationAccountAccessRole"
}
}
33 changes: 33 additions & 0 deletions infra/aws/terraform/kops-infra-ci/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2023 The Kubernetes Authors.
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 {
backend "s3" {
bucket = "k8s-infra-kops-ci-tf-state"
region = "us-east-2"
key = "kops-infra-ci/terraform.tfstate"
// TODO(ameukam): stop used hardcoded account id. Preferably use SSO user
role_arn = "arn:aws:iam::808842816990:role/OrganizationAccountAccessRole"
session_name = "kops-infra-ci"
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.11.0"
}
}
}
20 changes: 20 additions & 0 deletions infra/aws/terraform/kops-infra-ci/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2023 The Kubernetes Authors.
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_version = "~> 1.5.1"
}

0 comments on commit d2ba573

Please sign in to comment.