@@ -4,10 +4,181 @@ title: The AWS Secrets Manager credential manager
44
55## Configuration
66
7+ In order to integrate with AWS Secrets Manager for credential management, the web node must be configured with:
8+
9+ * an access key and secret key, or a session token
10+ * the AWS region that your parameters are stored within.
11+
12+ If no access key, secret key, or session token is provided, Concourse will attempt to use environment variables or the
13+ instance credentials assigned to the instance.
14+
15+ The web node's configuration specifies the following:
16+
17+ ** ` aws-secretsmanager-access-key ` ** : string
18+
19+ : A valid AWS access key.
20+
21+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_ACCESS_KEY ` .
22+
23+ ** ` aws-secretsmanager-secret-key ` ** : string
24+
25+ : The secret key that corresponds to the access key defined above.
26+
27+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_SECRET_KEY ` .
28+
29+ ** ` aws-secretsmanager-session-token ` ** : string
30+
31+ : A valid AWS session token.
32+
33+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_SESSION_TOKEN ` .
34+
35+ ** ` aws-secretsmanager-region ` ** : string
36+
37+ : The AWS region that requests to Secrets Manager will be sent to.
38+
39+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_REGION ` .
40+
41+ ** ` aws-secretsmanager-pipeline-secret-template ` ** : string
42+
43+ : The base path used when attempting to locate a pipeline-level secret.
44+
45+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_PIPELINE_SECRET_TEMPLATE ` .
46+
47+ : !!! example
48+
49+ Default: `/concourse/{{.Team}}/{{.Pipeline}}/{{.Secret}}`
50+
51+ ** ` aws-secretsmanager-team-secret-template ` ** : string
52+
53+ : The base path used when attempting to locate a team-level secret.
54+
55+ : Environment variable ` CONCOURSE_AWS_SECRETSMANAGER_TEAM_SECRET_TEMPLATE ` .
56+
57+ : !!! example
58+
59+ Default: `/concourse/{{.Team}}/{{.Secret}}`
60+
61+ For example, to launch the ATC and enable Secrets Manager, you may configure:
62+
63+ ``` shell
64+ concourse web ... \
65+ --aws-secretsmanager-region us-east-1 \
66+ --aws-secretsmanager-access-key AKIAIOSFODNN7EXAMPLE \
67+ --aws-secretsmanager-secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
68+
69+ # or use env variables
70+ CONCOURSE_AWS_SECRETSMANAGER_REGION=" us-east-1" \
71+ CONCOURSE_AWS_SECRETSMANAGER_ACCESS_KEY=" AKIAIOSFODNN7EXAMPLE" \
72+ CONCOURSE_AWS_SECRETSMANAGER_SECRET_KEY=" wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
73+ concourse web ...
74+ ```
75+
76+ A more secure method is to configure
77+ an [ IAM role] ( https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html ) for your EC2 ATC
78+ instance so that credentials are fetched automatically from the EC2 metadata service.
79+
780## Saving credentials in AWS
881
82+ It seems to be best to use the 'other type of secret' option and the 'plaintext' entry (otherwise your secrets will be
83+ interpolated as JSON) for best results. Make sure your secret locations match the lookup templates exactly; include the
84+ leading ` / ` , for example.
85+
986## IAM Permissions
1087
88+ The following is an example of an IAM policy that can be used to grant permissions to an IAM user or instance role. Note
89+ that the ` Resource ` section can contain a wildcard to a secret or be restricted to an individual secret. In order for
90+ the health check to work properly (see [ Scaling] ( #scaling ) ), Concourse needs to have access to
91+ the ` __concourse-health-check ` secret.
92+
93+ ``` json
94+ {
95+ "Version" : " 2012-10-17" ,
96+ "Statement" : [
97+ {
98+ "Sid" : " AllowAccessToSecretManagerParameters" ,
99+ "Effect" : " Allow" ,
100+ "Action" : [
101+ " secretsmanager:ListSecrets"
102+ ],
103+ "Resource" : " *"
104+ },
105+ {
106+ "Sid" : " AllowAccessGetSecret" ,
107+ "Effect" : " Allow" ,
108+ "Action" : [
109+ " secretsmanager:GetSecretValue" ,
110+ " secretsmanager:DescribeSecret"
111+ ],
112+ "Resource" : [
113+ " arn:aws:secretsmanager:*:*:secret:/concourse/*" ,
114+ " arn:aws:secretsmanager:*:*:secret:__concourse-health-check-??????"
115+ ]
116+ }
117+ ]
118+ }
119+ ```
120+
121+ If you wish to restrict concourse to only have access to secrets for a specific pipeline, you can
122+ replace ` "arn:aws:secretsmanager:*:*:secret:/concourse/*" ` in the example above with:
123+
124+ ``` json
125+ {
126+ "Version" : " 2012-10-17" ,
127+ "Statement" : [
128+ {
129+ "Sid" : " AllowAccessToSecretManagerParameters" ,
130+ "Effect" : " Allow" ,
131+ "Action" : [
132+ " secretsmanager:ListSecrets"
133+ ],
134+ "Resource" : " *"
135+ },
136+ {
137+ "Sid" : " AllowAccessGetSecret" ,
138+ "Effect" : " Allow" ,
139+ "Action" : [
140+ " secretsmanager:GetSecretValue" ,
141+ " secretsmanager:DescribeSecret"
142+ ],
143+ "Resource" : [
144+ " arn:aws:secretsmanager:*:*:secret:/concourse/TEAM_NAME/*" ,
145+ " arn:aws:secretsmanager:*:*:secret:/concourse/TEAM_NAME/PIPELINE_NAME/*" ,
146+ " arn:aws:secretsmanager:*:*:secret:__concourse-health-check-??????"
147+ ]
148+ }
149+ ]
150+ }
151+ ```
152+
153+ where ` TEAM_NAME ` and ` PIPELINE_NAME ` are replaced with the team and name of the pipeline in question.
154+
155+ For more information on how to use IAM roles to restrict access to Secrets Manager, review
156+ the [ official documentation] ( https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_identity-based-policies.html ) .
157+
11158## Credential Lookup Rules
12159
13- ## Scaling
160+ When resolving a parameter such as ` ((foo_param)) ` , Concourse will look in the following paths, in order:
161+
162+ * ` /concourse/TEAM_NAME/PIPELINE_NAME/foo_param `
163+ * ` /concourse/TEAM_NAME/foo_param `
164+
165+ The leading ` /concourse ` can be changed by specifying ` --aws-secretsmanager-pipeline-secret-template `
166+ or ` --aws-secretsmanager-team-secret-template ` variables.
167+
168+ !!! note
169+
170+ If Concourse does not have [permission](#iam-permissions) to access the pipeline-scoped paths, then credential
171+ lookups will fail even for credentials which are stored at the team level.
172+
173+ ## Scaling
174+
175+ If your cluster has a large workload, in particular if there are many resources, Concourse can generate a lot of traffic
176+ to AWS and subsequently get rate-limited.
177+
178+ As long as Concourse has permission to get the value of the ` __concourse-health-check ` secret, you should be able to
179+ measure an error rate by polling the ` /api/v1/info/creds ` endpoint when authenticated as
180+ a [ Concourse Admin] ( ../../auth-and-teams/user-roles.md#concourse-admin ) .
181+
182+ Depending on your workflow for updating secrets and your reliability requirements it may be
183+ worth [ Caching credentials] ( caching.md ) and/or [ Retrying failed fetches] ( retrying-failed.md ) to mitigate
184+ rate-limit-related errors.
0 commit comments