Skip to content

Commit 42865a8

Browse files
Update the SMCE docs
1 parent 4baab9a commit 42865a8

File tree

3 files changed

+66
-80
lines changed

3 files changed

+66
-80
lines changed

docs/howto/archive-homedir.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- aws access to the cluster
2+
3+
4+
Create a bucket in S3:
5+
aws s3 s3://jmte-prod-homedirs-archive --region us-west-2
6+
aws s3 ls
7+
8+
9+
Create a role with no permissions:
10+
aws iam get-role --role-name homedirs-archive-access
11+
12+
13+
Create a policy that can write into that bucket, and attach it to the role we just created:
14+
15+
aws iam put-role-policy --role-name homedirs-archive-access --policy-name HomedirsArchiveAccess_policy --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":["arn:aws:s3:::jmte-prod-homedirs-archive","arn:aws:s3:::jmte-prod-homedirs-archive/*"]}]}'
16+
17+
18+
python3 archive-home-dirs.py \
19+
--archive-name="archive-$(date +'%Y-%m-%d')" \
20+
--basedir=/home/jovyan/allusers/ \
21+
--bucket-name=jmte-prod-homedirs-archive \
22+
--object-prefix="archives/" \
23+
--usernames-file=to_archive.txt \
24+
--temp-path=/home/jovyan/archive-staging/

docs/howto/regenerate-smce-creds.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Regenerate credentials for NASA SMDC accounts
1+
# Regenerate credentials for NASA SMDE accounts
22

33
This document describes how we regenerate credentials for _users_ and the `deployer` when they expire in NASA SMDC accounts.
44

@@ -55,19 +55,3 @@ This document describes how we regenerate credentials for _users_ and the `deplo
5555
```
5656
5757
You can then open a Pull Request and merge it.
58-
59-
(nasa-smce:regenerate-user-password)=
60-
## Regenerate a password for a user in a NASA SMDC account
61-
62-
The AWS accounts associated with NASA's [Science Managed Cloud Environment](https://smce.nasa.gov)
63-
have a 60 day password expiry policy. If someone on the team misses this
64-
deadline, we can actually reset passwords for each other!
65-
66-
1. Someone in the team with access logs into the AWS console of the appropriate project
67-
2. Follow [AWS's user guide on resetting passwords](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_passwords_admin-change-user.html#id_credentials_passwords_admin-change-user_console)
68-
for whoever's 60 day window has elpased
69-
3. In addition, a `AccountDisabled` IAM Group will be automatically added to the
70-
user whenever their credentials expire, and this will show up as a "cannot
71-
change password" error when the user logs in next. So the user should also be
72-
removed from this group. You can do so from under the "Groups" tab in the
73-
AWS console when looking at the details of this user.

docs/hub-deployment-guide/new-cluster/smce.md

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22

33
Cloud resources for NASA's [Science Managed Cloud Environment](https://smce.nasa.gov/) (SMCE) is managed via an AWS organization and access via a SSO service.
44

5+
Once the steps below are done, steps for the regular [AWS Cluster Setup](new-cluster:new-cluster) can proceed,
6+
until completion of [provisioning credentials for CI/CD](new-cluster:terraform:cluster-credentials).
7+
8+
## Getting an account
9+
10+
1. The community representative will get in touch with SMCE to setup a Science Cloud account for each 2i2c member.
11+
2. This account will have to be added by the community to their AWS SSO.
12+
3. We will then be able to login each of the SMCE AWS accounts we have access to.
13+
514
## Signing into the AWS SSO
615

7-
To sign into the AWS SSO, you need to go to the [SMCE portal](https://aws.sciencecloud.nasa.gov/). Your Science Cloud identity is tied to your 2i2c.org email address and managed via Microsoft online. Here are the steps to follow:
16+
### Via the UI
17+
18+
To sign into the AWS SSO, you need to go to the [SMDC portal](https://aws.sciencecloud.nasa.gov/). Your Science Cloud identity is tied to your 2i2c.org email address and managed via Microsoft online. Here are the steps to follow:
819

920
1. Visit the following link: [http://aws.sciencecloud.nasa.gov/](http://aws.sciencecloud.nasa.gov/)
1021
1. Login using your 2i2c.org email address
@@ -18,78 +29,45 @@ Select the permission level you need to perform your work, and you will be direc
1829

1930
You can also copy and paste the access keys you require into your terminal to use the AWS CLI.
2031

21-
## Getting an account
22-
23-
This is very much the same as getting access to any other AWS account where billing is handled for us by someone else.
24-
25-
1. The community representative will get in touch with SMCE to either provision a new
26-
AWS account, or grant us full access to one that already exists.
27-
28-
2. Once the community representative has access, they will create an
29-
IAM account for *one* 2i2c engineer in this account, and make sure
30-
they are a part of the `SMCE-ProjectAdmins` group. This gives us
31-
full access to the AWS account, and we can add other engineers here.
32-
33-
3. This engineer should log in with the credentials provided by the community representative, and set up [Multi Factor Authentication](https://aws.amazon.com/iam/features/mfa/), using [this dashboard link](https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-west-2#/security_credentials/mfa). This is required in all SMCE environments. You need to log out of the AWS console and back in after setting up MFA to see your full permissions.
32+
### Via the terminal
33+
Follow the instructions at [](cloud-access:aws-sso:terminal) to get access into the cluster.
3434

35-
4. This engineer should now create user accounts for all other 2i2c engineers, and make sure they are all part of the `SMCE-ProjectAdmins` group.
35+
The rest of the process should be the same.
3636

37-
Once this is done, steps for the regular [AWS Cluster Setup](new-cluster:new-cluster) can proceed,
38-
until completion of [provisioning credentials for CI/CD](new-cluster:terraform:cluster-credentials).
37+
## Get eksctl access into the cluster for everyone using an AWS SSO user
38+
39+
1. Login into the hub via the terminal following the steps linked above.
40+
2. Assume the Project-Admin role for the cluster you want to get access to.
41+
2. Get the exact role name assumed by the SSO user as follows:
42+
```bash
43+
role=$(aws sts get-caller-identity --query "Arn" --output text | grep --only-matching -E "AWS[^\/]+")
44+
```
45+
3. From the role name, determine the ARN
46+
```bash
47+
arn=$(aws iam get-role --role-name "$role" --output text --query Role.Arn)
48+
```
49+
4. Create an access entry for this ARN
50+
```bash
51+
aws eks create-access-entry --cluster-name "$CLUSTER_NAME" --principal-arn "$arn" --region "$REGION"
52+
```
53+
5. Associate that access entry with the AmazonEKSClusterAdminPolicy
54+
```bash
55+
aws eks associate-access-policy \
56+
--cluster-name "$CLUSTER_NAME" \
57+
--region "$REGION" \
58+
--principal-arn "$arn" \
59+
--policy-arn arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy \
60+
--access-scope type=cluster
61+
```
3962

4063
## `hub-continuous-deployer` user
4164

42-
By default, we don't have permissions to create additional IAM users. This is a problem for our continuous deployer user `hub-continuous-deployer`. SMCE / SMDC is able to grant us exemptions though.
43-
44-
### SMDE
65+
By default, we don't have permissions to create additional IAM users. This is a problem for our continuous deployer user `hub-continuous-deployer`. SMCE is able to grant us exemptions though.
4566

4667
Right now, SMDE has to manually create the account named `hub-continuous-deployer`. This
4768
has to be requested through their internal systems (that are opaque to us). Once created,
4869
we can import that into our terraform with `terraform import -var-file=projects/${project}.tfvars aws_iam_user.continuous_deployer hub-continuous-deployer`.
4970

50-
The rest of the process should be the same.
51-
52-
### SMCE
53-
54-
The process for SMCE is a bit different. We can create the user account, but there's a
55-
MFA requirement that must be exempted.
56-
57-
At the completion of [provisioning credentials for CI/CD](new-cluster:terraform:cluster-credentials),
58-
we will have a IAM user named `hub-continuous-deployer` provisioned. This is what we use to
59-
deploy from GitHub actions, but also to deploy from our local machines. The MFA requirement
60-
needs to be exempted for this user before we can continue and actually deploy our hubs.
61-
62-
The engineer needs to reach out to the community representative at this point, and ask
63-
for the MFA exemption. `hub-continuous-deployer` has a very narrow scope of permissions - only
64-
`eks:DescribeCluster` on the specific cluster we deployed. The community representative will
65-
have to reach out via their own internal processes to grant this exemption. This has
66-
always been granted so far - VEDA, GHG - and should not be a problem to get granted again.
67-
We have also received assurances that this process would be expedited to the extent possible.
68-
69-
You can verify that this MFA exemption has been processed by looking at the list of groups
70-
the `hub-continuous-deployer` user belongs to. It should *not* contain the user `SMCE-UserRestrictions`.
71-
72-
Once this exemption has been processed, you can continue as usual with deployment of the hub.
73-
74-
## Preparing for routine regeneration of the `hub-continuous-deployer` access credentials
75-
76-
The `hub-continuous-deployer` has an access key and secret associated with it, this is how it
77-
authenticates with AWS to perform actions. SMCE accounts have a 60 day password/access key
78-
regeneration policy and so we need to prepare to regularly regenerate this access key.
79-
See [](nasa-smce:regenerate-deployer-creds) for how to reset the credentials.
80-
81-
```{warning}
82-
We only receive **5 days notice** that a password/access key will expire via email!
83-
84-
Also it is unclear who receives this email: all engineers or just the engineer who
85-
setup the cluster?
86-
```
87-
88-
```{note}
89-
See [](nasa-smce:regenerate-user-password) for how to reset an expired password for
90-
a _user_, e.g., a member of the engineering team.
91-
```
92-
9371
## Cost allocation tags
9472

9573
[Cost allocation tags](howto:cost-monitoring:activate-tags) have been enabled at the AWS organization level for SMCE. Therefore we do not need to enable them with our terraform configuration, i.e. the variable `enable_cost_allocation_tags` is set to `false` by default, so we do not need to include this in the `projects/<project>.tfvars` file.

0 commit comments

Comments
 (0)