-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added tf infra for AWS ami account
This adds AWS infra provisioning using terraform for the AWS account to be used to publish CAPA AMIs. Signed-off-by: Richard Case <[email protected]>
- Loading branch information
1 parent
0c64536
commit d3086f6
Showing
7 changed files
with
318 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,41 @@ | ||
# AWS Account for CAPA AMI Publication | ||
|
||
This contains Terraform used to manage users & permissions for the **cncf-k8s-infra-aws-capa-ami** AWS account (`arn:aws:organizations::348685125169:account/o-kz4vlkihvy/819546954734`). | ||
|
||
## Tool Requirements | ||
|
||
* [Terraform](https://developer.hashicorp.com/terraform/downloads) v1.6.0 or greater | ||
* AWS CLI | ||
|
||
## Pre-reqs | ||
|
||
This will need to be run by someone that is an admin in the account or by someone that can assume role to give admin in the account. | ||
|
||
## Running | ||
|
||
Set the AWS environment variables for the user that has access to the account. | ||
|
||
Then run the following to disable the blocking of public AMIs: | ||
|
||
```bash | ||
hack/disable-block.sh | ||
``` | ||
|
||
> NOTE: the script is used to disable the block as it doesn't naturally fit well into Terraform when running it across many regions. | ||
Then do the usual terraform flow: | ||
|
||
```bash | ||
terraform apply | ||
terraform plan | ||
``` | ||
|
||
If its the first time its been run you can then supply the CAPA maintainers with the initial passwords for their IAM accounts. | ||
|
||
Also one of the maintainers will need to be given the access key id and secret got IAM account to be used for automation. These have been encrypted with the gpg of one of the maintainers. | ||
|
||
## Adding users | ||
|
||
The CAPA maintainers have been added as IAM users. The iam user name matches their GitHub username. | ||
|
||
Where possible the the user should be defined with **pgp_key** so that the initial password for the IAM user is encrypted. |
27 changes: 27 additions & 0 deletions
27
infra/aws/terraform/cncf-k8s-infra-aws-capa-ami/hack/disable-block.sh
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2024 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. | ||
|
||
## This script is used to disable the block on public access to AMIs | ||
|
||
AMI_REGIONS="ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2" | ||
|
||
IFS=',' | ||
read -ra arr <<<"$AMI_REGIONS" | ||
|
||
for val in "${arr[@]}"; do | ||
printf "Disabling the block on public AMIs in region $val\n" | ||
aws ec2 disable-image-block-public-access --region $val | ||
done |
37 changes: 37 additions & 0 deletions
37
infra/aws/terraform/cncf-k8s-infra-aws-capa-ami/iam-capa-maintainers-group.tf
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,37 @@ | ||
/* | ||
Copyright 2024 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. | ||
*/ | ||
|
||
resource "aws_iam_group" "maintainers" { | ||
name = "maintainers" | ||
} | ||
|
||
resource "aws_iam_group_membership" "maintainers" { | ||
name = "capa-maintainers" | ||
|
||
users = [ | ||
aws_iam_user.ankitasw.name, | ||
aws_iam_user.dlipovetsky.name, | ||
aws_iam_user.richardcase.name, | ||
aws_iam_user.vincepri.name, | ||
] | ||
|
||
group = aws_iam_group.maintainers.name | ||
} | ||
|
||
resource "aws_iam_group_policy_attachment" "maintainer-admin" { | ||
group = aws_iam_group.maintainers.name | ||
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess" | ||
} |
64 changes: 64 additions & 0 deletions
64
infra/aws/terraform/cncf-k8s-infra-aws-capa-ami/iam-capa-maintainers-users.tf
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,64 @@ | ||
/* | ||
Copyright 2024 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. | ||
*/ | ||
|
||
|
||
resource "aws_iam_user" "ankitasw" { | ||
name = "ankitasw" | ||
} | ||
resource "aws_iam_user_login_profile" "ankitasw_login" { | ||
user = aws_iam_user.ankitasw.name | ||
password_reset_required = true | ||
} | ||
|
||
output "ankitasw_password" { | ||
value = aws_iam_user_login_profile.ankitasw_login.encrypted_password | ||
} | ||
|
||
resource "aws_iam_user" "dlipovetsky" { | ||
name = "dlipovetsky" | ||
} | ||
resource "aws_iam_user_login_profile" "dlipovetsky_login" { | ||
user = aws_iam_user.dlipovetsky.name | ||
password_reset_required = true | ||
} | ||
|
||
output "dlipovetsky_password" { | ||
value = aws_iam_user_login_profile.dlipovetsky_login.encrypted_password | ||
} | ||
|
||
resource "aws_iam_user" "richardcase" { | ||
name = "richardcase" | ||
} | ||
resource "aws_iam_user_login_profile" "richardcase_login" { | ||
user = aws_iam_user.richardcase.name | ||
pgp_key = "mQINBGKe9M0BEACqiPeuyj4wm7uIfLqeYxDwj6QFf9D/vxnusBEy3Y7AoIUsRE7hAIAIkKxFseqPsz1BjhZFUHyz7W81He4LH5NafzjR//Rb0h6acmJARHSyrBJsDC837CPxJJaVkhX2Y2rim+MJyqsPUxvCoEY+9mf1z6IOQLFS1eglGxyo7SI4JvZtNUS/SXfa1LhaQ11DtuVB0MPd86xCaXLMr5gUOreh63IySuXIZibeUNpZeqAVsm0OKhHb8qDSo2tCKUqUB4lCF4VkOnqetO4lQQlMHrW6S6O/HQ8X/PPXVVvR8L8IjDLVEp5UcIgQwNmy3uCOR6AYj6OpMxGLg9iTyidB2JPV+bynkanjWYXQAnHwfhL2F67ihPvV0FqX52n+WUdYjxqLV/sZcIDj9FNIvw+6043q7hx2N80p/aaX6yFHZmcw4ygpTblgWw/7JTu1gGtASY6Jik95UiyDmEOrLdo7PNQyajkKsTvEVHwHEI8SEMpJr1fLrJms5QDebG9vtfEAFa3a2/nv0tfv+eTBMSKLvjvAmh88m5rQjRaIi971N2BlYTkdsCgQQPV+kwT2vtuI12RAn/ykH76WuEjXVtEliQPVwrAJQxTAWND481Q7SohQI9VcdhARV66gCctTaooWQdTYDd2FU61XA4FEo7QV8czrcc1pnzSLOLU+Acr3NQMkrwARAQABtCdSaWNoYXJkIENhc2UgPHJpY2hhcmQuY2FzZUBvdXRsb29rLmNvbT6JAlcEEwEKAEECGwMFCQPCZwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AWIQQhvJMGF6FmKNZ2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5AvAEwgQJWCUHCOW/pAso/IDArUxqX32q0r/qJ5KIqcnDpPFtDoiV30MaZrTFz9Qj9Z4qLusJpULO4GWYwwVmB2q7J6/1CfxZiuEYxd3OcAahdbp998pCmQIvbdGBOvzMP1grX1dxBeIdDDBgn/emKa++a6HPb19PHawclpQV0EuHxQ9a3m9ymlr1E/8lpOfqImN6N0Kd4/pUvHILhxJ7ABEBAAGJAjwEGAEKACYWIQQhvJMGF6FmKNZ2lAsxfINc3qmMzQUCYp70zQIbDAUJA8JnAAAKCRAxfINc3qmMzR6PEACbSFg5y+wp8e4vdCJKpxMOLxzlZ1hOikfJQ5XnllagNTktvP8CGVcgdbutDOOZ3j+0lDXS7+QF19LzoIrpMiY5R1eQOfaiqbWMoe+f2cM4h60yScjHP/+DT7SZ9WHgG2a2BqZ/6/ixcwMT570nObDTCK3RR8pyY+KpFJY/9XFhc7l4tSz1Jx851noQvVFLEPqSEILAIg46V/tb9eiZ+LkpapDEksqnoyU5eS0uO770zeCFRWh9DesH14qLNmFwgYO2Rh5sYNtNp12G1Mzy1I6VSpaBZBh/CaKP6oaNG/0xJiY5m74kN9aTLRwBScbLIMT07KBM919oLRHjzDaMj657xTYLSqlew2q5XHqjTosopXHpRier/67MBU5LmleJ0ipTDDu+5cKlXteU9pIBj4YgyBVC/PtSHO3SbvDR7xdgFJs7JitkazONMrKf1ejXO/QF62MnRlGttAn96yJz4quowMIUFD1Fl8Vjj2/mCDQiPtYvjy/5s5Qoz+F3CJxejEEaaxSivdvg3bECkzEA2Ii/SZ9Nr8o9yDByOUHo16a1qEoxfSfpsvU0c30oUL+jYk2FlT80JnTf8VQczE+Q/M0E6/q/xI5C5nW9bYT8A1Dln47VGBmtGxkNZETilda5IjNyU4rmsAO6GxFalk3woAGBQ9XmDj1pyrieUbcj1k22QA==" | ||
password_reset_required = true | ||
} | ||
output "richardcase_password" { | ||
value = aws_iam_user_login_profile.richardcase_login.encrypted_password | ||
} | ||
|
||
resource "aws_iam_user" "vincepri" { | ||
name = "vincepri" | ||
} | ||
resource "aws_iam_user_login_profile" "vincepri_login" { | ||
user = aws_iam_user.vincepri.name | ||
password_reset_required = true | ||
} | ||
|
||
output "vincepri_password" { | ||
value = aws_iam_user_login_profile.vincepri_login.encrypted_password | ||
} |
Oops, something went wrong.