Skip to content

Commit df2c91d

Browse files
authored
Simplify aws policy by adding cortex prefix to queue name (#1941)
1 parent 5596c88 commit df2c91d

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

cli/cmd/cluster.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ var _clusterUpCmd = &cobra.Command{
188188
LogGroup: clusterConfig.ClusterName,
189189
Bucket: clusterConfig.Bucket,
190190
Region: clusterConfig.Region,
191-
SQSPrefix: clusterconfig.SQSNamePrefix(clusterConfig.ClusterName),
192191
AccountID: accountID,
193192
})
194193
if err != nil {

docs/clusters/aws/auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ _NOTE: The policy created during `cortex cluster up` will automatically be delet
7777
{
7878
"Effect": "Allow",
7979
"Action": "sqs:*",
80-
"Resource": "arn:aws:sqs:{{ .Region }}:{{ .AccountID }}:{{ .SQSPrefix }}*"
80+
"Resource": "arn:aws:sqs:{{ .Region }}:{{ .AccountID }}:cortex-*"
8181
},
8282
{
8383
"Effect": "Allow",

pkg/operator/resources/job/batchapi/queue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func apiQueueNamePrefix(apiName string) string {
3535
return config.CoreConfig.SQSNamePrefix() + apiName + "-"
3636
}
3737

38-
// QueueName is <hash of cluster name>-<api_name>-<job_id>.fifo
38+
// QueueName is cortex-<hash of cluster name>-<api_name>-<job_id>.fifo
3939
func getJobQueueName(jobKey spec.JobKey) string {
4040
return apiQueueNamePrefix(jobKey.APIName) + jobKey.ID + ".fifo"
4141
}
@@ -57,7 +57,7 @@ func jobKeyFromQueueURL(queueURL string) spec.JobKey {
5757

5858
jobID := strings.TrimSuffix(dashSplit[len(dashSplit)-1], ".fifo")
5959

60-
apiNameSplit := dashSplit[1 : len(dashSplit)-1]
60+
apiNameSplit := dashSplit[2 : len(dashSplit)-1]
6161
apiName := strings.Join(apiNameSplit, "-")
6262

6363
return spec.JobKey{APIName: apiName, ID: jobID}

pkg/types/clusterconfig/aws_policy.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var _cortexPolicy = `
5353
{
5454
"Effect": "Allow",
5555
"Action": "sqs:*",
56-
"Resource": "arn:aws:sqs:{{ .Region }}:{{ .AccountID }}:{{ .SQSPrefix }}*"
56+
"Resource": "arn:aws:sqs:{{ .Region }}:{{ .AccountID }}:cortex-*"
5757
},
5858
{
5959
"Effect": "Allow",
@@ -89,7 +89,6 @@ type CortexPolicyTemplateArgs struct {
8989
LogGroup string
9090
Region string
9191
Bucket string
92-
SQSPrefix string
9392
AccountID string
9493
}
9594

pkg/types/clusterconfig/cluster_config_aws.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,8 +682,8 @@ func (cc *Config) ToAccessConfig() AccessConfig {
682682
}
683683

684684
func SQSNamePrefix(clusterName string) string {
685-
// 10 was chosen to make sure that other identifiers can be added to the full queue name before reaching the 80 char SQS name limit
686-
return hash.String(clusterName)[:10] + "-"
685+
// 8 was chosen to make sure that other identifiers can be added to the full queue name before reaching the 80 char SQS name limit
686+
return "cortex-" + hash.String(clusterName)[:8] + "-"
687687
}
688688

689689
// returns hash of cluster name and adds trailing "-"

0 commit comments

Comments
 (0)