11
11
AWS_ASSET_UPLOAD_ROLE_ARN :
12
12
description : ' ARN of the IAM role to assume to upload assets to S3'
13
13
required : true
14
+ AWS_ACCOUNT_ID_FRESH_SETUP_TESTS :
15
+ description : ' AWS Account ID to use for setting up IAM permissions and running tests'
16
+ required : true
17
+ ARTILLERY_CLOUD_ENDPOINT_TEST :
18
+ description : ' Artillery Cloud endpoint for running tests'
19
+ required : true
20
+ ARTILLERY_CLOUD_API_KEY_TEST :
21
+ description : ' Artillery Cloud API Key for running tests'
22
+ required : true
23
+ DD_TESTS_API_KEY :
24
+ description : ' Datadog API Key for running tests'
25
+ required : true
26
+ DD_TESTS_APP_KEY :
27
+ description : ' Datadog App Key for running tests'
28
+ required : true
14
29
15
30
workflow_dispatch :
16
31
inputs :
22
37
env :
23
38
CF_LAMBDA_TEMPLATE : ${{ inputs.canary && 'aws-iam-lambda-cf-template-canary.yml' || 'aws-iam-lambda-cf-template.yml' }}
24
39
CF_FARGATE_TEMPLATE : ${{ inputs.canary && 'aws-iam-fargate-cf-template-canary.yml' || 'aws-iam-fargate-cf-template.yml' }}
25
- GH_OIDC_LAMBDA_TEMPLATE : ${{ inputs.canary && 'gh -oidc-lambda- canary.yml' || 'gh -oidc-lambda .yml' }}
26
- GH_OIDC_FARGATE_TEMPLATE : ${{ inputs.canary && 'gh-oidc-fargate-canary.yml' || 'gh-oidc-fargate.yml' }}
40
+ GH_OIDC_TEMPLATE : ${{ inputs.canary && 'github -oidc-canary.yml' || 'github -oidc.yml' }}
41
+
27
42
jobs :
43
+ # Publish templates to AWS S3
28
44
put-cloudformation-templates :
29
45
runs-on : ubuntu-latest
30
46
@@ -50,5 +66,155 @@ jobs:
50
66
run : |
51
67
aws s3 cp --acl public-read ./packages/artillery/lib/platform/aws/iam-cf-templates/aws-iam-fargate-cf-template.yml s3://artilleryio-cf-templates/${{ env.CF_FARGATE_TEMPLATE }}
52
68
aws s3 cp --acl public-read ./packages/artillery/lib/platform/aws/iam-cf-templates/aws-iam-lambda-cf-template.yml s3://artilleryio-cf-templates/${{ env.CF_LAMBDA_TEMPLATE }}
53
- aws s3 cp --acl public-read ./packages/artillery/lib/platform/aws/iam-cf-templates/gh-oidc-lambda.yml s3://artilleryio-cf-templates/${{ env.GH_OIDC_LAMBDA_TEMPLATE }}
54
- aws s3 cp --acl public-read ./packages/artillery/lib/platform/aws/iam-cf-templates/gh-oidc-fargate.yml s3://artilleryio-cf-templates/${{ env.GH_OIDC_FARGATE_TEMPLATE }}
69
+ aws s3 cp --acl public-read ./packages/artillery/lib/platform/aws/iam-cf-templates/github-oidc.yml s3://artilleryio-cf-templates/${{ env.GH_OIDC_TEMPLATE }}
70
+
71
+ # This job is used to test that the IAM role created from the `github-oidc.yml` CF template has the correct permissions to be able to run Artillery tests on Lambda and Fargate and that the OIDC is set correctly.
72
+ set-up-and-run-artillery-test-on-aws :
73
+ runs-on : ubuntu-latest
74
+
75
+ permissions :
76
+ id-token : write
77
+ contents : read
78
+ needs : put-cloudformation-templates
79
+ strategy :
80
+ matrix :
81
+ service : [lambda, fargate]
82
+ include :
83
+ - service : lambda
84
+ test-file : ' test/cloud-e2e/lambda/lambda-smoke.test.js'
85
+ - service : fargate
86
+ test-file : ' test/cloud-e2e/fargate/dd-adot.test.js'
87
+ max-parallel : 1
88
+
89
+ steps :
90
+ - name : Checkout code
91
+ uses : actions/checkout@v2
92
+
93
+ - name : Configure AWS Credentials
94
+ uses : aws-actions/configure-aws-credentials@v2
95
+ env :
96
+ SHOW_STACK_TRACE : true
97
+ with :
98
+ aws-region : us-east-1
99
+ role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_FRESH_SETUP_TESTS }}:role/ResetAccountForRunningTests
100
+ role-session-name : OIDCSession
101
+ mask-aws-account-id : true
102
+
103
+ - name : Install aws-nuke
104
+ run : |
105
+ curl -sL https://github.com/rebuy-de/aws-nuke/releases/download/v2.25.0/aws-nuke-v2.25.0-linux-amd64.tar.gz | tar -xz
106
+ sudo install aws-nuke-v2.25.0-linux-amd64 /usr/local/bin/aws-nuke
107
+
108
+ - name : Run aws-nuke
109
+ run : |
110
+ cat <<EOF > aws-nuke-config.yml
111
+ regions:
112
+ - "global"
113
+ - "us-east-2"
114
+ - "us-east-1"
115
+ - "us-west-1"
116
+ - "us-west-2"
117
+ - "ap-south-1"
118
+ - "ap-northeast-3"
119
+ - "ap-northeast-2"
120
+ - "ap-southeast-1"
121
+ - "ap-southeast-2"
122
+ - "ap-northeast-1"
123
+ - "ca-central-1"
124
+ - "eu-central-1"
125
+ - "eu-west-1"
126
+ - "eu-west-2"
127
+ - "eu-west-3"
128
+ - "eu-north-1"
129
+ - "sa-east-1"
130
+
131
+ account-blocklist:
132
+ - 111111111111
133
+
134
+ resource-types:
135
+ targets:
136
+ - IAMRole
137
+ - IAMPolicy
138
+ - IAMRolePolicyAttachment
139
+ - IAMOpenIDConnectProvider
140
+ - S3Bucket
141
+ - S3Object
142
+ - LambdaFunction
143
+ - ECSTaskDefinition
144
+ - ECSCluster
145
+ - ECSContainerInstance
146
+ - CloudFormationStack
147
+ - SQSQueue
148
+ - CloudWatchLogGroup
149
+ - CloudWatchLogStream
150
+ - SSMParameter
151
+
152
+ accounts:
153
+ "${{ secrets.AWS_ACCOUNT_ID_FRESH_SETUP_TESTS }}":
154
+ filters:
155
+ IAMRole:
156
+ - property: Name
157
+ type: "glob"
158
+ value: "AWS*"
159
+ - property: Name
160
+ type: "glob"
161
+ value: "Organization*"
162
+ - property: Name
163
+ value: "ResetAccountForRunningTests"
164
+
165
+ IAMRolePolicyAttachment:
166
+ - property: RoleName
167
+ type: "glob"
168
+ value: "AWS*"
169
+ - property: RoleName
170
+ value: "ResetAccountForRunningTests"
171
+ - property: RoleName
172
+ type: "glob"
173
+ value: "Organization*"
174
+
175
+ IAMOpenIDConnectProvider:
176
+ - property: Arn
177
+ type: "contains"
178
+ value: "oidc-provider/token.actions.githubusercontent.com"
179
+ invert: true
180
+ EOF
181
+
182
+ aws-nuke --config aws-nuke-config.yml --force --force-sleep 4 --no-dry-run
183
+
184
+ - name : Fetch CloudFormation Template
185
+ run : |
186
+ aws s3 cp s3://artilleryio-cf-templates/${{ env.GH_OIDC_TEMPLATE }} template.yml
187
+ - name : Deploy CloudFormation Template
188
+ run : |
189
+ aws cloudformation create-stack \
190
+ --stack-name iam-distributed-testing-setup \
191
+ --template-body file://template.yml \
192
+ --parameters ParameterKey=GitHubRepository,ParameterValue="artilleryio/artillery" \
193
+ --capabilities CAPABILITY_NAMED_IAM
194
+ aws cloudformation wait stack-create-complete --stack-name iam-distributed-testing-setup
195
+
196
+ - name : Configure AWS Credentials
197
+ uses : aws-actions/configure-aws-credentials@v2
198
+ env :
199
+ SHOW_STACK_TRACE : true
200
+ with :
201
+ aws-region : us-east-1
202
+ role-to-assume : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_FRESH_SETUP_TESTS }}:role/ArtilleryGitHubOIDCRole
203
+ role-session-name : OIDCSession
204
+ mask-aws-account-id : true
205
+ - name : Use Node.js 18.x
206
+ uses : actions/setup-node@v2
207
+ with :
208
+ node-version : 18.x
209
+ - run : .github/workflows/scripts/npm-command-retry.sh install
210
+ - run : npm run build
211
+ - name : Run Artillery Test
212
+ env :
213
+ ARTILLERY_CLOUD_ENDPOINT : ${{ secrets.ARTILLERY_CLOUD_ENDPOINT_TEST }}
214
+ ARTILLERY_CLOUD_API_KEY : ${{ secrets.ARTILLERY_CLOUD_API_KEY_TEST }}
215
+ FORCE_COLOR : 1
216
+ DD_TESTS_API_KEY : ${{ secrets.DD_TESTS_API_KEY }}
217
+ DD_TESTS_APP_KEY : ${{ secrets.DD_TESTS_APP_KEY }}
218
+ run : |
219
+ npm run test:aws:ci --workspace artillery -- --files ${{ matrix.test-file }}
220
+
0 commit comments