Skip to content

Commit edbd376

Browse files
committed
Add typing and cleanup
1 parent 310e375 commit edbd376

22 files changed

+142
-199
lines changed

tests/ci/cdk/README.md

+4-23
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ Use these commands to deploy the CI pipeline. Any changes to the CI or Docker im
8787

8888
These commands are run from `aws-lc/tests/ci/cdk`.
8989

90-
If not done previously, bootstrap cdk for the pipeline account before running the next commands.
90+
[SKIP IF NO CROSS-ACCOUNT DEPLOYMENT] Give the pipeline account administrator access to the deployment account's CloudFormation. Repeat this step depending on how many deployment environment there are. You only need to run this step once when the pipeline is deploying to a new account for the first time.
9191
```
92-
cdk bootstrap aws://${PIPELINE_ACCOUNT_ID}/us-west-2
92+
cdk bootstrap aws://${DEPLOY_ACCOUNT_ID}/us-west-2 --trust ${PIPELINE_ACCOUNT_ID} --trust-for-lookup ${PIPELINE_ACCOUNT_ID} --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
9393
```
9494

95-
[SKIP IF NO CROSS-ACCOUNT DEPLOYMENT] Give the pipeline account administrator access to the deployment account's CloudFormation. Repeat this step depending on how many deployment environment there are. You only need to run this step once when the pipeline is deploying to a new account for the first time.
95+
If not done previously, bootstrap cdk for the pipeline account before running the next commands.
9696
```
97-
cdk bootstrap aws://${DEPLOY_ACCOUNT_ID}/us-west-2 --trust ${PIPELINE_ACCOUNT_ID} --trust-for-lookup ${PIPELINE_ACCOUNT_ID} --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
97+
cdk bootstrap aws://${PIPELINE_ACCOUNT_ID}/us-west-2
9898
```
9999

100100
To deploy dev pipeline to the same account as your CI:
@@ -112,25 +112,6 @@ To deploy production pipeline using default parameters:
112112
./run-cdk.sh --action deploy-production-pipeline
113113
```
114114

115-
<!-- Bootstrap pipeline account
116-
```
117-
AWS_ACCOUNT_ID=183295444613
118-
PIPELINE_ACCOUNT_ID=774305600158
119-
cdk bootstrap aws://${PIPELINE_ACCOUNT_ID}/us-west-2
120-
```
121-
122-
Give pipeline account administrator access to deployment account's CloudFormation
123-
```
124-
cdk bootstrap aws://${AWS_ACCOUNT_ID}/us-west-2 --trust ${PIPELINE_ACCOUNT_ID} --trust-for-lookup ${PIPELINE_ACCOUNT_ID} --cloudformation-execution-policies arn:aws:iam::aws:policy/AdministratorAccess
125-
```
126-
127-
Deploy pipeline
128-
```
129-
GITHUB_REPO_OWNER=nhatnghiho
130-
GITHUB_SOURCE_VERSION=ci-pipeline
131-
./run-cdk.sh --github-repo-owner ${GITHUB_REPO_OWNER} --github-source-version ${GITHUB_SOURCE_VERSION} --aws-account ${AWS_ACCOUNT_ID} --action invoke --command "cdk deploy AwsLcCiPipeline --require-approval never"
132-
``` -->
133-
134115
### CI Commands
135116
Use these commands if you wish to deploy individual stacks instead of the entire pipeline.
136117

tests/ci/cdk/cdk/aws_lc_analytics_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(self,
2020
scope: Construct,
2121
id: str,
2222
spec_file_path: str,
23-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
23+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
2424
**kwargs) -> None:
2525
super().__init__(scope, id, env=env, **kwargs)
2626

tests/ci/cdk/cdk/aws_lc_android_ci_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self,
2222
scope: Construct,
2323
id: str,
2424
spec_file_path: str,
25-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
25+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
2626
**kwargs) -> None:
2727
super().__init__(scope, id, env=env, **kwargs)
2828

tests/ci/cdk/cdk/aws_lc_ec2_test_framework_ci_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self,
2727
scope: Construct,
2828
id: str,
2929
spec_file_path: str,
30-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
30+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
3131
**kwargs) -> None:
3232
super().__init__(scope, id, env=env, **kwargs)
3333

tests/ci/cdk/cdk/aws_lc_github_ci_stack.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from cdk.components import PruneStaleGitHubBuilds
1010
from util.iam_policies import code_build_batch_policy_in_json, code_build_publish_metrics_in_json, \
11-
code_build_cloudwatch_logs_policy_in_json, s3_read_policy_in_json
11+
code_build_cloudwatch_logs_policy_in_json
1212
from util.metadata import GITHUB_PUSH_CI_BRANCH_TARGETS, GITHUB_REPO_OWNER, GITHUB_REPO_NAME, \
1313
PIPELINE_ACCOUNT, PRE_PROD_ACCOUNT, STAGING_GITHUB_REPO_OWNER, STAGING_GITHUB_REPO_NAME
1414
from util.build_spec_loader import BuildSpecLoader
@@ -21,7 +21,7 @@ def __init__(self,
2121
scope: Construct,
2222
id: str,
2323
spec_file_path: str,
24-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
24+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
2525
**kwargs) -> None:
2626
super().__init__(scope, id, env=env, **kwargs)
2727

@@ -52,7 +52,6 @@ def __init__(self,
5252
code_build_cloudwatch_logs_policy = iam.PolicyDocument.from_json(
5353
code_build_cloudwatch_logs_policy_in_json([log_group])
5454
)
55-
s3_assets_policy = iam.PolicyDocument.from_json(s3_read_policy_in_json())
5655
resource_access_role = iam.Role(scope=self,
5756
id="{}-resource-role".format(id),
5857
assumed_by=iam.CompositePrincipal(
@@ -61,7 +60,6 @@ def __init__(self,
6160
),
6261
inline_policies={
6362
"code_build_cloudwatch_logs_policy": code_build_cloudwatch_logs_policy,
64-
"s3_assets_policy": s3_assets_policy
6563
})
6664

6765
# Define a IAM role for this stack.

tests/ci/cdk/cdk/aws_lc_github_ci_x509_stack.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
GITHUB_REPO_OWNER, PRE_PROD_ACCOUNT, STAGING_GITHUB_REPO_OWNER, STAGING_GITHUB_REPO_NAME,
1010
)
1111

12-
1312
class AwsLcGitHubX509CIStack(Stack):
1413
def __init__(
1514
self,
1615
scope: Construct,
1716
id: str,
18-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
17+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
1918
**kwargs,
2019
) -> None:
2120
super().__init__(scope, id, env=env, **kwargs)

tests/ci/cdk/cdk/aws_lc_github_fuzz_ci_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self,
2222
scope: Construct,
2323
id: str,
2424
spec_file_path: str,
25-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
25+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
2626
**kwargs) -> None:
2727
super().__init__(scope, id, env=env, **kwargs)
2828

tests/ci/cdk/cdk/components.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pathlib
2+
import typing
23

3-
from aws_cdk import aws_codebuild as codebuild, aws_lambda as lambda_, aws_ecr_assets as ecr_assets, aws_secretsmanager as sm, \
4-
aws_events as events, aws_events_targets as events_targets, aws_iam as iam, Duration
4+
from aws_cdk import aws_codebuild as codebuild, aws_lambda as lambda_, aws_ecr_assets as ecr_assets, \
5+
aws_secretsmanager as sm, \
6+
aws_events as events, aws_events_targets as events_targets, aws_iam as iam, Duration, Environment
57

68
from constructs import Construct
79
from util.metadata import GITHUB_REPO_OWNER, GITHUB_TOKEN_SECRET_NAME
@@ -14,7 +16,7 @@ def __init__(
1416
id: str,
1517
*,
1618
project: codebuild.IProject,
17-
env,
19+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
1820
ec2_permissions: bool
1921
) -> None:
2022
super().__init__(scope, id)

tests/ci/cdk/cdk/linux_docker_image_batch_build_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(
2626
self,
2727
scope: Construct,
2828
id: str,
29-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
29+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
3030
**kwargs) -> None:
3131
super().__init__(scope, id, env=env, **kwargs)
3232

tests/ci/cdk/cdk/windows_docker_image_build_stack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(
3434
self,
3535
scope: Construct,
3636
id: str,
37-
env: typing.Optional[typing.Union[Environment, typing.Dict[str, typing.Any]]],
37+
env: typing.Union[Environment, typing.Dict[str, typing.Any]],
3838
**kwargs) -> None:
3939
super().__init__(
4040
scope,

0 commit comments

Comments
 (0)