Skip to content

Commit bf4ab40

Browse files
authored
Remove aws credentials flags (#1944)
1 parent 2781037 commit bf4ab40

File tree

5 files changed

+23
-122
lines changed

5 files changed

+23
-122
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cluster-up-aws:
6868
@$(MAKE) images-all-aws
6969
@$(MAKE) cli
7070
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
71-
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster up ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --cluster-aws-key="$$CLUSTER_AWS_ACCESS_KEY_ID" --cluster-aws-secret="$$CLUSTER_AWS_SECRET_ACCESS_KEY"
71+
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster up ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws"
7272
@$(MAKE) kubectl-aws
7373
cluster-up-gcp:
7474
@$(MAKE) images-all-gcp
@@ -81,7 +81,7 @@ cluster-up-aws-y:
8181
@$(MAKE) images-all-aws
8282
@$(MAKE) cli
8383
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
84-
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster up ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --cluster-aws-key="$$CLUSTER_AWS_ACCESS_KEY_ID" --cluster-aws-secret="$$CLUSTER_AWS_SECRET_ACCESS_KEY" --yes
84+
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster up ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --yes
8585
@$(MAKE) kubectl-aws
8686
cluster-up-gcp-y:
8787
@$(MAKE) images-all-gcp
@@ -94,7 +94,7 @@ cluster-down-aws:
9494
@$(MAKE) images-manager-skip-push
9595
@$(MAKE) cli
9696
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
97-
@./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret=$$AWS_SECRET_ACCESS_KEY
97+
@./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml
9898
cluster-down-gcp:
9999
@$(MAKE) images-manager-skip-push
100100
@$(MAKE) cli
@@ -105,7 +105,7 @@ cluster-down-aws-y:
105105
@$(MAKE) images-manager-skip-push
106106
@$(MAKE) cli
107107
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
108-
@./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --yes
108+
@./bin/cortex cluster down --config=./dev/config/cluster-aws.yaml --yes
109109
cluster-down-gcp-y:
110110
@$(MAKE) images-manager-skip-push
111111
@$(MAKE) cli
@@ -115,7 +115,7 @@ cluster-down-gcp-y:
115115
cluster-info-aws:
116116
@$(MAKE) images-manager-skip-push
117117
@$(MAKE) cli
118-
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster info --config=./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --yes
118+
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster info --config=./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --yes
119119
cluster-info-gcp:
120120
@$(MAKE) images-manager-skip-push
121121
@$(MAKE) cli
@@ -125,7 +125,7 @@ cluster-configure-aws:
125125
@$(MAKE) images-all-aws
126126
@$(MAKE) cli
127127
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
128-
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster configure ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --cluster-aws-key="$$CLUSTER_AWS_ACCESS_KEY_ID" --cluster-aws-secret="$$CLUSTER_AWS_SECRET_ACCESS_KEY"
128+
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster configure ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws"
129129
# cluster-configure-gcp:
130130
# @$(MAKE) images-all-gcp
131131
# @$(MAKE) cli
@@ -136,7 +136,7 @@ cluster-configure-aws-y:
136136
@$(MAKE) images-all-aws
137137
@$(MAKE) cli
138138
@kill $(shell pgrep -f rerun) >/dev/null 2>&1 || true
139-
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster configure ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --aws-key="$$AWS_ACCESS_KEY_ID" --aws-secret="$$AWS_SECRET_ACCESS_KEY" --cluster-aws-key="$$CLUSTER_AWS_ACCESS_KEY_ID" --cluster-aws-secret="$$CLUSTER_AWS_SECRET_ACCESS_KEY" --yes
139+
@eval $$(python3 ./manager/cluster_config_env.py ./dev/config/cluster-aws.yaml) && ./bin/cortex cluster configure ./dev/config/cluster-aws.yaml --configure-env="$$CORTEX_CLUSTER_NAME-aws" --yes
140140
# cluster-configure-gcp-y:
141141
# @$(MAKE) images-all-gcp
142142
# @$(MAKE) cli

cli/cmd/cluster.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ var (
6767

6868
func clusterInit() {
6969
_clusterUpCmd.Flags().SortFlags = false
70-
addAWSCredentialsFlags(_clusterUpCmd)
71-
addClusterAWSCredentialsFlags(_clusterUpCmd)
7270
_clusterUpCmd.Flags().StringVarP(&_flagClusterUpEnv, "configure-env", "e", "aws", "name of environment to configure")
7371
_clusterUpCmd.Flags().BoolVarP(&_flagClusterDisallowPrompt, "yes", "y", false, "skip prompts")
7472
_clusterCmd.AddCommand(_clusterUpCmd)
@@ -77,15 +75,12 @@ func clusterInit() {
7775
addClusterConfigFlag(_clusterInfoCmd)
7876
addClusterNameFlag(_clusterInfoCmd)
7977
addClusterRegionFlag(_clusterInfoCmd)
80-
addAWSCredentialsFlags(_clusterInfoCmd)
8178
_clusterInfoCmd.Flags().StringVarP(&_flagClusterInfoEnv, "configure-env", "e", "", "name of environment to configure")
8279
_clusterInfoCmd.Flags().BoolVarP(&_flagClusterInfoDebug, "debug", "d", false, "save the current cluster state to a file")
8380
_clusterInfoCmd.Flags().BoolVarP(&_flagClusterDisallowPrompt, "yes", "y", false, "skip prompts")
8481
_clusterCmd.AddCommand(_clusterInfoCmd)
8582

8683
_clusterConfigureCmd.Flags().SortFlags = false
87-
addAWSCredentialsFlags(_clusterConfigureCmd)
88-
addClusterAWSCredentialsFlags(_clusterConfigureCmd)
8984
_clusterConfigureCmd.Flags().StringVarP(&_flagClusterConfigureEnv, "configure-env", "e", "", "name of environment to configure")
9085
_clusterConfigureCmd.Flags().BoolVarP(&_flagClusterDisallowPrompt, "yes", "y", false, "skip prompts")
9186
_clusterCmd.AddCommand(_clusterConfigureCmd)
@@ -94,7 +89,6 @@ func clusterInit() {
9489
addClusterConfigFlag(_clusterDownCmd)
9590
addClusterNameFlag(_clusterDownCmd)
9691
addClusterRegionFlag(_clusterDownCmd)
97-
addAWSCredentialsFlags(_clusterDownCmd)
9892
_clusterDownCmd.Flags().BoolVarP(&_flagClusterDisallowPrompt, "yes", "y", false, "skip prompts")
9993
_clusterDownCmd.Flags().BoolVar(&_flagClusterDownKeepVolumes, "keep-volumes", false, "keep cortex provisioned persistent volumes")
10094
_clusterCmd.AddCommand(_clusterDownCmd)
@@ -103,7 +97,6 @@ func clusterInit() {
10397
addClusterConfigFlag(_clusterExportCmd)
10498
addClusterNameFlag(_clusterExportCmd)
10599
addClusterRegionFlag(_clusterExportCmd)
106-
addAWSCredentialsFlags(_clusterExportCmd)
107100
_clusterCmd.AddCommand(_clusterExportCmd)
108101
}
109102

@@ -120,16 +113,6 @@ func addClusterRegionFlag(cmd *cobra.Command) {
120113
cmd.Flags().StringVarP(&_flagClusterRegion, "region", "r", "", "aws region of the cluster")
121114
}
122115

123-
func addAWSCredentialsFlags(cmd *cobra.Command) {
124-
cmd.Flags().StringVar(&_flagAWSAccessKeyID, "aws-key", "", "aws access key id")
125-
cmd.Flags().StringVar(&_flagAWSSecretAccessKey, "aws-secret", "", "aws secret access key")
126-
}
127-
128-
func addClusterAWSCredentialsFlags(cmd *cobra.Command) {
129-
cmd.Flags().StringVar(&_flagClusterAWSAccessKeyID, "cluster-aws-key", "", "aws access key id to be used by the cluster")
130-
cmd.Flags().StringVar(&_flagClusterAWSSecretAccessKey, "cluster-aws-secret", "", "aws secret access key to be used by the cluster")
131-
}
132-
133116
var _clusterCmd = &cobra.Command{
134117
Use: "cluster",
135118
Short: "manage AWS clusters (contains subcommands)",
@@ -160,11 +143,6 @@ var _clusterUpCmd = &cobra.Command{
160143
exit.Error(err)
161144
}
162145

163-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
164-
if err := detectAWSCredsInConfigFile(cmd.Use, clusterConfigFile); err != nil {
165-
exit.Error(err)
166-
}
167-
168146
accessConfig, err := getNewClusterAccessConfig(clusterConfigFile)
169147
if err != nil {
170148
exit.Error(err)
@@ -325,11 +303,6 @@ var _clusterConfigureCmd = &cobra.Command{
325303
exit.Error(err)
326304
}
327305

328-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
329-
if err := detectAWSCredsInConfigFile(cmd.Use, clusterConfigFile); err != nil {
330-
exit.Error(err)
331-
}
332-
333306
accessConfig, err := getClusterAccessConfigWithCache()
334307
if err != nil {
335308
exit.Error(err)
@@ -393,11 +366,6 @@ var _clusterInfoCmd = &cobra.Command{
393366
exit.Error(err)
394367
}
395368

396-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
397-
if err := detectAWSCredsInConfigFile(cmd.Use, _flagClusterConfig); err != nil {
398-
exit.Error(err)
399-
}
400-
401369
accessConfig, err := getClusterAccessConfigWithCache()
402370
if err != nil {
403371
exit.Error(err)
@@ -427,11 +395,6 @@ var _clusterDownCmd = &cobra.Command{
427395
exit.Error(err)
428396
}
429397

430-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
431-
if err := detectAWSCredsInConfigFile(cmd.Use, _flagClusterConfig); err != nil {
432-
exit.Error(err)
433-
}
434-
435398
accessConfig, err := getClusterAccessConfigWithCache()
436399
if err != nil {
437400
exit.Error(err)
@@ -548,11 +511,6 @@ var _clusterExportCmd = &cobra.Command{
548511
Run: func(cmd *cobra.Command, args []string) {
549512
telemetry.Event("cli.cluster.export", map[string]interface{}{"provider": types.AWSProviderType})
550513

551-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
552-
if err := detectAWSCredsInConfigFile(cmd.Use, _flagClusterConfig); err != nil {
553-
exit.Error(err)
554-
}
555-
556514
accessConfig, err := getClusterAccessConfigWithCache()
557515
if err != nil {
558516
exit.Error(err)

cli/cmd/errors.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,28 +223,6 @@ func ErrorOnlyAWSClusterEnvVarSet() error {
223223
})
224224
}
225225

226-
func ErrorOnlyAWSClusterFlagSet() error {
227-
return errors.WithStack(&errors.Error{
228-
Kind: ErrOnlyAWSClusterFlagSet,
229-
Message: "when specifying --cluster-aws-key and --cluster-aws-secret, please also specify --aws-key and --aws-secret",
230-
})
231-
}
232-
233-
func ErrorMissingAWSCredentials() error {
234-
return errors.WithStack(&errors.Error{
235-
Kind: ErrMissingAWSCredentials,
236-
Message: "unable to find aws credentials; please specify aws credentials using the flags --aws-key and --aws-secret",
237-
})
238-
}
239-
240-
// Deprecation: specifying aws creds in cluster configuration is no longer supported
241-
func ErrorCredentialsInClusterConfig(cmd string, path string) error {
242-
return errors.WithStack(&errors.Error{
243-
Kind: ErrCredentialsInClusterConfig,
244-
Message: fmt.Sprintf("specifying credentials in the cluster configuration is no longer supported, please specify aws credentials using flags (e.g. cortex cluster %s --config %s --aws-key <AWS_ACCESS_KEY_ID> --aws-secret <AWS_SECRET_ACCESS_KEY>) or set environment variables; see https://docs.cortex.dev/v/%s/ for more information", cmd, path, consts.CortexVersionMinor),
245-
})
246-
}
247-
248226
func ErrorClusterUp(out string) error {
249227
return errors.WithStack(&errors.Error{
250228
Kind: ErrClusterUp,

cli/cmd/lib_aws_creds.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import (
2121

2222
"github.com/cortexlabs/cortex/pkg/consts"
2323
"github.com/cortexlabs/cortex/pkg/lib/aws"
24-
cr "github.com/cortexlabs/cortex/pkg/lib/configreader"
25-
"github.com/cortexlabs/cortex/pkg/lib/errors"
26-
27-
"github.com/cortexlabs/cortex/pkg/lib/sets/strset"
2824

2925
"github.com/cortexlabs/cortex/pkg/lib/prompt"
3026
"github.com/cortexlabs/cortex/pkg/types/clusterconfig"
@@ -75,20 +71,3 @@ func warnIfNotAdmin(awsClient *aws.Client) {
7571
fmt.Println(fmt.Sprintf("warning: your IAM user or assumed role%s does not have administrator access. This may prevent this command from executing correctly, so it is recommended to attach the AdministratorAccess policy to your IAM user or role.", accessKeyMsg), "", "")
7672
}
7773
}
78-
79-
// Deprecation: specifying aws creds in cluster configuration is no longer supported; returns an error if aws credentials were found in cluster configuration yaml
80-
func detectAWSCredsInConfigFile(cmd, path string) error {
81-
credentialFieldKeys := strset.New("aws_access_key_id", "aws_secret_access_key", "cortex_aws_access_key_id", "cortex_aws_secret_access_key")
82-
fieldMap, err := cr.ReadYAMLFileStrMap(path)
83-
if err != nil {
84-
return nil
85-
}
86-
87-
for key := range fieldMap {
88-
if credentialFieldKeys.Has(key) {
89-
return errors.Wrap(ErrorCredentialsInClusterConfig(cmd, path), path, key)
90-
}
91-
}
92-
93-
return nil
94-
}

docs/clients/cli.md

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,9 @@ Usage:
101101
cortex cluster up [CLUSTER_CONFIG_FILE] [flags]
102102
103103
Flags:
104-
--aws-key string aws access key id
105-
--aws-secret string aws secret access key
106-
--cluster-aws-key string aws access key id to be used by the cluster
107-
--cluster-aws-secret string aws secret access key to be used by the cluster
108-
-e, --configure-env string name of environment to configure (default "aws")
109-
-y, --yes skip prompts
110-
-h, --help help for up
104+
-e, --configure-env string name of environment to configure (default "aws")
105+
-y, --yes skip prompts
106+
-h, --help help for up
111107
```
112108

113109
## cluster info
@@ -122,8 +118,6 @@ Flags:
122118
-c, --config string path to a cluster configuration file
123119
-n, --name string name of the cluster
124120
-r, --region string aws region of the cluster
125-
--aws-key string aws access key id
126-
--aws-secret string aws secret access key
127121
-e, --configure-env string name of environment to configure
128122
-d, --debug save the current cluster state to a file
129123
-y, --yes skip prompts
@@ -139,13 +133,9 @@ Usage:
139133
cortex cluster configure [CLUSTER_CONFIG_FILE] [flags]
140134
141135
Flags:
142-
--aws-key string aws access key id
143-
--aws-secret string aws secret access key
144-
--cluster-aws-key string aws access key id to be used by the cluster
145-
--cluster-aws-secret string aws secret access key to be used by the cluster
146-
-e, --configure-env string name of environment to configure
147-
-y, --yes skip prompts
148-
-h, --help help for configure
136+
-e, --configure-env string name of environment to configure
137+
-y, --yes skip prompts
138+
-h, --help help for configure
149139
```
150140

151141
## cluster down
@@ -157,14 +147,12 @@ Usage:
157147
cortex cluster down [flags]
158148
159149
Flags:
160-
-c, --config string path to a cluster configuration file
161-
-n, --name string name of the cluster
162-
-r, --region string aws region of the cluster
163-
--aws-key string aws access key id
164-
--aws-secret string aws secret access key
165-
-y, --yes skip prompts
166-
--keep-volumes keep cortex provisioned persistent volumes
167-
-h, --help help for down
150+
-c, --config string path to a cluster configuration file
151+
-n, --name string name of the cluster
152+
-r, --region string aws region of the cluster
153+
-y, --yes skip prompts
154+
--keep-volumes keep cortex provisioned persistent volumes
155+
-h, --help help for down
168156
```
169157

170158
## cluster export
@@ -176,12 +164,10 @@ Usage:
176164
cortex cluster export [API_NAME] [API_ID] [flags]
177165
178166
Flags:
179-
-c, --config string path to a cluster configuration file
180-
-n, --name string name of the cluster
181-
-r, --region string aws region of the cluster
182-
--aws-key string aws access key id
183-
--aws-secret string aws secret access key
184-
-h, --help help for export
167+
-c, --config string path to a cluster configuration file
168+
-n, --name string name of the cluster
169+
-r, --region string aws region of the cluster
170+
-h, --help help for export
185171
```
186172

187173
## cluster-gcp up

0 commit comments

Comments
 (0)