diff --git a/apis/v1alpha1/ack-generate-metadata.yaml b/apis/v1alpha1/ack-generate-metadata.yaml index 723361a..c9211c0 100755 --- a/apis/v1alpha1/ack-generate-metadata.yaml +++ b/apis/v1alpha1/ack-generate-metadata.yaml @@ -1,8 +1,8 @@ ack_generate_info: - build_date: "2022-06-14T04:56:33Z" - build_hash: a133935a9a93591a9e1ba9d5ca940cb83a1353b4 + build_date: "2022-06-17T18:12:25Z" + build_hash: a45f3b900849ec03c5e16ed2778c0b8e2923ffee go_version: go1.17.5 - version: v0.19.0 + version: v0.19.1 api_directory_checksum: 6a10685980ee0dfddcf83fb3555f58e31d1e24c1 api_version: v1alpha1 aws_sdk_go_version: v1.42.0 diff --git a/config/controller/kustomization.yaml b/config/controller/kustomization.yaml index 93065e4..a8a961a 100644 --- a/config/controller/kustomization.yaml +++ b/config/controller/kustomization.yaml @@ -6,4 +6,4 @@ kind: Kustomization images: - name: controller newName: public.ecr.aws/aws-controllers-k8s/applicationautoscaling-controller - newTag: v0.2.10 + newTag: v0.2.11 diff --git a/go.mod b/go.mod index 690473c..789a3eb 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/aws-controllers-k8s/applicationautoscaling-controller go 1.17 require ( - github.com/aws-controllers-k8s/runtime v0.19.0 + github.com/aws-controllers-k8s/runtime v0.19.1 github.com/aws/aws-sdk-go v1.42.0 github.com/ghodss/yaml v1.0.0 github.com/go-logr/logr v1.2.0 diff --git a/go.sum b/go.sum index 9ad075b..f2cf742 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/aws-controllers-k8s/runtime v0.19.0 h1:+O5a6jBSBAd8XTNMrVCIYu4G+ZUPZe/G5eopVFO18Dc= -github.com/aws-controllers-k8s/runtime v0.19.0/go.mod h1:oA8ML1/LL3chPn26P6SzBNu1CUI2nekB+PTqykNs0qU= +github.com/aws-controllers-k8s/runtime v0.19.1 h1:OBV7vbIbLFRpXdAwJfoPGphhjTa7xSc3pS/kuYlKzRU= +github.com/aws-controllers-k8s/runtime v0.19.1/go.mod h1:oA8ML1/LL3chPn26P6SzBNu1CUI2nekB+PTqykNs0qU= github.com/aws/aws-sdk-go v1.42.0 h1:BMZws0t8NAhHFsfnT3B40IwD13jVDG5KerlRksctVIw= github.com/aws/aws-sdk-go v1.42.0/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= diff --git a/helm/Chart.yaml b/helm/Chart.yaml index f972f90..fd313c7 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 name: applicationautoscaling-chart description: A Helm chart for the ACK service controller for AWS Auto Scaling (AutoScaling) -version: v0.2.10 -appVersion: v0.2.10 +version: v0.2.11 +appVersion: v0.2.11 home: https://github.com/aws-controllers-k8s/applicationautoscaling-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt index 7215a4b..1530d04 100644 --- a/helm/templates/NOTES.txt +++ b/helm/templates/NOTES.txt @@ -1,5 +1,5 @@ {{ .Chart.Name }} has been installed. -This chart deploys "public.ecr.aws/aws-controllers-k8s/applicationautoscaling-controller:v0.2.10". +This chart deploys "public.ecr.aws/aws-controllers-k8s/applicationautoscaling-controller:v0.2.11". Check its status by running: kubectl --namespace {{ .Release.Namespace }} get pods -l "app.kubernetes.io/instance={{ .Release.Name }}" diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl index 29265d7..973704c 100644 --- a/helm/templates/_helpers.tpl +++ b/helm/templates/_helpers.tpl @@ -36,3 +36,13 @@ If release name contains chart name it will be used as a full name. {{- .Release.Namespace -}} {{- end -}} {{- end -}} + +{{/* The mount path for the shared credentials file */}} +{{- define "aws.credentials.secret_mount_path" -}} +{{- "/var/run/secrets/aws" -}} +{{- end -}} + +{{/* The path the shared credentials file is mounted */}} +{{- define "aws.credentials.path" -}} +{{- printf "%s/%s" (include "aws.credentials.secret_mount_path" .) .Values.aws.credentials.secretKey -}} +{{- end -}} diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index d3a307a..9fd82f7 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -80,6 +80,16 @@ spec: value: {{ .Values.log.level | quote }} - name: ACK_RESOURCE_TAGS value: {{ join "," .Values.resourceTags | quote }} + {{- if .Values.aws.credentials.secretName }} + - name: AWS_SHARED_CREDENTIALS_FILE + value: {{ include "aws.credentials.path" . }} + - name: AWS_PROFILE + value: {{ .Values.aws.credentials.profile }} + volumeMounts: + - name: {{ .Values.aws.credentials.secretName }} + mountPath: {{ include "aws.credentials.secret_mount_path" . }} + readOnly: true + {{- end }} securityContext: allowPrivilegeEscalation: false privileged: false @@ -101,3 +111,9 @@ spec: hostIPC: false hostNetwork: false hostPID: false + {{ if .Values.aws.credentials.secretName -}} + volumes: + - name: {{ .Values.aws.credentials.secretName }} + secret: + secretName: {{ .Values.aws.credentials.secretName }} + {{ end -}} diff --git a/helm/values.schema.json b/helm/values.schema.json index e503248..c80422e 100644 --- a/helm/values.schema.json +++ b/helm/values.schema.json @@ -153,6 +153,21 @@ }, "endpoint": { "type": "string" + }, + "credentials": { + "description": "AWS credentials information", + "properties": { + "secretName": { + "type": "string" + }, + "secretKey": { + "type": "string" + }, + "profile": { + "type": "string" + } + }, + "type": "object" } }, "type": "object" diff --git a/helm/values.yaml b/helm/values.yaml index 50488d7..c6fb5ac 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -4,7 +4,7 @@ image: repository: public.ecr.aws/aws-controllers-k8s/applicationautoscaling-controller - tag: v0.2.10 + tag: v0.2.11 pullPolicy: IfNotPresent pullSecrets: [] @@ -50,6 +50,13 @@ aws: # If specified, use the AWS region for AWS API calls region: "" endpoint_url: "" + credentials: + # If specified, Secret with shared credentials file to use. + secretName: "" + # Secret stringData key that contains the credentials + secretKey: "credentials" + # Profile used for AWS credentials + profile: "default" # log level for the controller log: diff --git a/pkg/resource/scalable_target/manager.go b/pkg/resource/scalable_target/manager.go index 577d1b8..cf4d1ce 100644 --- a/pkg/resource/scalable_target/manager.go +++ b/pkg/resource/scalable_target/manager.go @@ -126,6 +126,9 @@ func (rm *resourceManager) Create( } created, err := rm.sdkCreate(ctx, r) if err != nil { + if created != nil { + return rm.onError(created, err) + } return rm.onError(r, err) } return rm.onSuccess(created) @@ -153,6 +156,9 @@ func (rm *resourceManager) Update( } updated, err := rm.sdkUpdate(ctx, desired, latest, delta) if err != nil { + if updated != nil { + return rm.onError(updated, err) + } return rm.onError(latest, err) } return rm.onSuccess(updated) diff --git a/pkg/resource/scalable_target/sdk.go b/pkg/resource/scalable_target/sdk.go index e10ec6a..5bdca3a 100644 --- a/pkg/resource/scalable_target/sdk.go +++ b/pkg/resource/scalable_target/sdk.go @@ -54,7 +54,9 @@ func (rm *resourceManager) sdkFind( ) (latest *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkFind") - defer exit(err) + defer func() { + exit(err) + }() // If any required fields in the input shape are missing, AWS resource is // not created yet. Return NotFound here to indicate to callers that the // resource isn't yet created. @@ -180,7 +182,9 @@ func (rm *resourceManager) sdkCreate( ) (created *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkCreate") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newCreateRequestPayload(ctx, desired) if err != nil { return nil, err @@ -254,7 +258,9 @@ func (rm *resourceManager) sdkUpdate( ) (updated *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkUpdate") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newUpdateRequestPayload(ctx, desired) if err != nil { return nil, err @@ -326,7 +332,9 @@ func (rm *resourceManager) sdkDelete( ) (latest *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkDelete") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newDeleteRequestPayload(r) if err != nil { return nil, err diff --git a/pkg/resource/scaling_policy/manager.go b/pkg/resource/scaling_policy/manager.go index 3e132ad..288de77 100644 --- a/pkg/resource/scaling_policy/manager.go +++ b/pkg/resource/scaling_policy/manager.go @@ -126,6 +126,9 @@ func (rm *resourceManager) Create( } created, err := rm.sdkCreate(ctx, r) if err != nil { + if created != nil { + return rm.onError(created, err) + } return rm.onError(r, err) } return rm.onSuccess(created) @@ -153,6 +156,9 @@ func (rm *resourceManager) Update( } updated, err := rm.sdkUpdate(ctx, desired, latest, delta) if err != nil { + if updated != nil { + return rm.onError(updated, err) + } return rm.onError(latest, err) } return rm.onSuccess(updated) diff --git a/pkg/resource/scaling_policy/sdk.go b/pkg/resource/scaling_policy/sdk.go index fc4b2bf..d1f24c0 100644 --- a/pkg/resource/scaling_policy/sdk.go +++ b/pkg/resource/scaling_policy/sdk.go @@ -54,7 +54,9 @@ func (rm *resourceManager) sdkFind( ) (latest *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkFind") - defer exit(err) + defer func() { + exit(err) + }() // If any required fields in the input shape are missing, AWS resource is // not created yet. Return NotFound here to indicate to callers that the // resource isn't yet created. @@ -278,7 +280,9 @@ func (rm *resourceManager) sdkCreate( ) (created *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkCreate") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newCreateRequestPayload(ctx, desired) if err != nil { return nil, err @@ -449,7 +453,9 @@ func (rm *resourceManager) sdkUpdate( ) (updated *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkUpdate") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newUpdateRequestPayload(ctx, desired) if err != nil { return nil, err @@ -618,7 +624,9 @@ func (rm *resourceManager) sdkDelete( ) (latest *resource, err error) { rlog := ackrtlog.FromContext(ctx) exit := rlog.Trace("rm.sdkDelete") - defer exit(err) + defer func() { + exit(err) + }() input, err := rm.newDeleteRequestPayload(r) if err != nil { return nil, err