Skip to content

Commit 94f7178

Browse files
authored
Release 3.3.11 (#139)
1 parent 310df86 commit 94f7178

12 files changed

+185
-19
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.3.11] - 2024-10-31
9+
10+
### Security
11+
12+
- Bumped http-proxy-middleware to `2.0.7` to mitigate [CVE-2024-21536](https://github.com/advisories/GHSA-c7qv-q95q-8v27)
13+
14+
### Changed
15+
16+
- Moved spoke service linked role template as conditional nested stack under spoke stack
17+
818
## [3.3.10] - 2024-10-10
919

1020
### Security
@@ -15,7 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1525

1626
### Security
1727

18-
- Bumped micromatch to `4.0.8` to mitigate [CVE-2024-4067](https://github.com/advisories/GHSA-952p-6rrq-rcjv)
28+
- Bumped micromatch to `4.0.8` to mitigate [CVE-2024-4067](https://github.com/advisories/GHSA-952p-6rrq-rcjv)
1929
- Bumped webpack to `5.94.0` to mitigate [CVE-2024-43788](https://github.com/advisories/GHSA-4vvj-4cpr-p986)
2030
- Bumped express to `4.21.0` to mitigate CVEs in sub-dependencies
2131
- Bump path-to-regexp to `6.3.0` to address [CVE-2024-45296](https://github.com/advisories/GHSA-9wv6-86v2-598j)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Use the following steps if you want to customize the solution or extend the solu
6868
Clone the repository and make desired code changes.
6969

7070
```
71-
git clone aws-solutions/network-orchestration-for-aws-transit-gateway
71+
git clone https://github.com/aws-solutions/network-orchestration-for-aws-transit-gateway.git
7272
```
7373

7474
_Note: The following steps have been tested under the preceding pre-requisites._

deployment/build-s3-dist.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
[ "$DEBUG" == 'true' ] && set -x
1818
set -e
1919

20-
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
20+
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]; then
2121
echo "Please provide the base source bucket name, trademark approved solution name and version where the lambda code will eventually reside."
22-
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0"
22+
echo "For example: ./build-s3-dist.sh solutions trademarked-solution-name v1.0.0 solutions-reference"
2323
exit 1
2424
fi
2525

@@ -159,4 +159,8 @@ else
159159
sed -i -e $replace $template_dist_dir/network-orchestration-organization-role.template
160160
sed -i -e $replace $template_dist_dir/network-orchestration-hub-service-linked-roles.template
161161
sed -i -e $replace $template_dist_dir/network-orchestration-spoke-service-linked-roles.template
162+
163+
# Replace template bucket name
164+
replace="s/%TEMPLATE_OUTPUT_BUCKET%/$4/g"
165+
sed -i -e $replace $template_dist_dir/network-orchestration-spoke.template
162166
fi

deployment/network-orchestration-spoke-service-linked-roles.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44
AWSTemplateFormatVersion: "2010-09-09"
55
Description: (SO0058s-slr) - The AWS CloudFormation template (Spoke) for deployment of the %SOLUTION_NAME% Solution. Version %VERSION%
66

7+
Parameters:
8+
ServiceLinkedRoleExist:
9+
Type: String
10+
Description: Does the service-linked role for AWS Transit Gateway already exist?
11+
Default: "False"
12+
13+
Conditions:
14+
CreateServiceLinkedRole: !Equals [ !Ref ServiceLinkedRoleExist, "False" ]
15+
716
Resources:
817
TransitGatewayServiceLinkedRole:
918
Type: "AWS::IAM::ServiceLinkedRole"
19+
Condition: CreateServiceLinkedRole
1020
Properties:
1121
AWSServiceName: "transitgateway.amazonaws.com"
1222
Description: Allows VPC Transit Gateway to access EC2 resources on your behalf.
1323

1424
Outputs:
1525
TransitGatewayServiceLinkedRoleName:
26+
Condition: CreateServiceLinkedRole
1627
Value: !Ref TransitGatewayServiceLinkedRole

deployment/network-orchestration-spoke.template

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ Mappings:
2828
EventBridge:
2929
Bus:
3030
Name: "Network-Orchestrator-Event-Bus"
31+
SourceCode:
32+
General:
33+
S3Bucket: "%DIST_BUCKET_NAME%"
34+
KeyPrefix: "network-orchestration-for-aws-transit-gateway/%VERSION%"
35+
Version: "%VERSION%"
36+
TemplateBucket: "%TEMPLATE_OUTPUT_BUCKET%"
37+
LambdaFunction:
38+
Logging:
39+
Level: "info"
3140

3241
Conditions:
3342
# Adding an EventBus as a target within an account is not allowed.
@@ -210,3 +219,77 @@ Resources:
210219
- arn:${AWS::Partition}:events:${AWS::Region}:${HubAccount}:event-bus/${EventBusName}
211220
- {EventBusName: !FindInMap [EventBridge, Bus, Name]}
212221

222+
# Lambda to check if the Transit Gateway service linked role already exist
223+
ServiceLinkedRoleCheckLambdaFunction:
224+
Type: AWS::Lambda::Function
225+
Metadata:
226+
cfn_nag:
227+
rules_to_suppress:
228+
- id: W92
229+
reason: "does not require concurrency reservation"
230+
- id: W89
231+
reason: "not a valid use-case for vpc"
232+
- id: W58
233+
reason: "log write permission added to CustomResourceLambdaFunctionRole"
234+
Properties:
235+
Environment:
236+
Variables:
237+
LOG_LEVEL: !FindInMap [LambdaFunction, Logging, Level]
238+
PARTITION: !Sub ${AWS::Partition}
239+
Code:
240+
S3Bucket: !Join ["-", [!FindInMap ["SourceCode", "General", "S3Bucket"], !Ref "AWS::Region"]]
241+
S3Key: !Join ["/", [!FindInMap ["SourceCode", "General", "KeyPrefix"],"custom_resource.zip"]]
242+
Description: Network Orchestration for AWS Transit Gateway - custom resource handler
243+
Handler: custom_resource.main.lambda_handler
244+
MemorySize: 512
245+
Role: !Sub ${CustomResourceLambdaFunctionRole.Arn}
246+
Runtime: python3.11
247+
Timeout: 900
248+
249+
CustomResourceLambdaFunctionRole:
250+
Type: AWS::IAM::Role
251+
Properties:
252+
AssumeRolePolicyDocument:
253+
Version: '2012-10-17'
254+
Statement:
255+
- Effect: Allow
256+
Principal:
257+
Service:
258+
- lambda.amazonaws.com
259+
Action: sts:AssumeRole
260+
Path: /
261+
Policies:
262+
- PolicyName: STNO-CWLogs-Policy
263+
PolicyDocument:
264+
Version: "2012-10-17"
265+
Statement:
266+
- Effect: Allow
267+
Action:
268+
- logs:CreateLogGroup
269+
- logs:CreateLogStream
270+
- logs:PutLogEvents
271+
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*
272+
- PolicyName: STNO-IAM-Policy
273+
PolicyDocument:
274+
Version: '2012-10-17'
275+
Statement:
276+
- Effect: Allow
277+
Action:
278+
- iam:GetRole
279+
Resource: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/*
280+
281+
CheckServiceLinkedRole:
282+
Type: "Custom::CheckServiceLinkedRole"
283+
Properties:
284+
ServiceToken: !GetAtt ServiceLinkedRoleCheckLambdaFunction.Arn
285+
286+
ServiceLinkedRoleNestedStack:
287+
Type: 'AWS::CloudFormation::Stack'
288+
Properties:
289+
TemplateURL: !Sub
290+
- "https://${Bucket}.s3.amazonaws.com/${Prefix}/network-orchestration-spoke-service-linked-roles.template"
291+
- Bucket: !FindInMap [ "SourceCode", "General", "TemplateBucket" ]
292+
Prefix: !FindInMap [ "SourceCode", "General", "KeyPrefix" ]
293+
Parameters:
294+
ServiceLinkedRoleExist:
295+
!GetAtt CheckServiceLinkedRole.ServiceLinkedRoleExist

source/cognito-trigger/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/cognito-trigger/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cognito-trigger",
3-
"version": "3.3.10",
3+
"version": "3.3.11",
44
"description": "Triggered when a new user is confirmed in the user pool to allow for custom actions to be taken",
55
"author": {
66
"name": "Amazon Web Services",

source/lambda/custom_resource/__tests__/test_custom_resource_helper.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from unittest.mock import Mock
88

99
import pytest
10+
import boto3
11+
from moto import mock_iam
1012
from aws_lambda_powertools import Logger
1113
from aws_lambda_powertools.utilities.typing import LambdaContext
1214

@@ -17,7 +19,8 @@
1719
handle_metrics,
1820
start_state_machine,
1921
send,
20-
get_resource_type_details
22+
get_resource_type_details,
23+
check_service_linked_role
2124
)
2225

2326
logger = Logger(os.getenv('LOG_LEVEL'))
@@ -51,6 +54,9 @@
5154
CREATE_METRICS = deepcopy(CFN_REQUEST_EVENT)
5255
CREATE_METRICS["ResourceType"] = "Custom::SendCFNParameters"
5356

57+
CHECK_SERVICE_LINKED_ROLE = deepcopy(CFN_REQUEST_EVENT)
58+
CHECK_SERVICE_LINKED_ROLE["ResourceType"] = "Custom::CheckServiceLinkedRole"
59+
5460
context = Mock()
5561
context.get_remaining_time_in_millis = Mock()
5662
context.get_remaining_time_in_millis.return_value = 10000
@@ -264,6 +270,26 @@ def test__success(self, mocker):
264270
handle_metrics(CREATE_METRICS)
265271

266272

273+
@pytest.mark.BDD
274+
@mock_iam
275+
class TestClassServiceLinkedRole:
276+
"""BDD class for testing checking if service linked role already exist"""
277+
iam_client = boto3.client("iam")
278+
service_linked_role_name = "AWSServiceRoleForVPCTransitGateway"
279+
280+
def test__true(self):
281+
"""true"""
282+
self.iam_client.create_role(RoleName=self.service_linked_role_name, AssumeRolePolicyDocument="some policy", Path="/my-path/")
283+
resp = check_service_linked_role(CHECK_SERVICE_LINKED_ROLE)
284+
self.iam_client.delete_role(RoleName=self.service_linked_role_name)
285+
286+
assert resp["ServiceLinkedRoleExist"] == "True"
287+
288+
def test__false(self):
289+
"""false"""
290+
resp = check_service_linked_role(CHECK_SERVICE_LINKED_ROLE)
291+
assert resp["ServiceLinkedRoleExist"] == "False"
292+
267293
@pytest.mark.TDD
268294
class TestClassTriggerSM:
269295
"""TDD test class to handle state machine execution"""
@@ -375,4 +401,4 @@ def test__success__fail(self, mocker):
375401

376402
class AWSLambdaContext:
377403
def __init__(self):
378-
self.invoked_function_arn = "abc:abc:abc:abc:abc:abc:abc"
404+
self.invoked_function_arn = "abc:abc:abc:abc:abc:abc:abc"

source/lambda/custom_resource/lib/custom_resource_helper.py

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from uuid import uuid4
1313

1414
import boto3
15+
from botocore.exceptions import ClientError
1516
from aws_lambda_powertools import Logger
1617
from aws_lambda_powertools.utilities.typing import LambdaContext
1718
from aws_lambda_typing import events
@@ -83,8 +84,6 @@ def get_tag_state(event):
8384
return "-deleted-"
8485

8586

86-
87-
8887
def timeout(event: events.CloudFormationCustomResourceEvent, context: LambdaContext):
8988
"""_summary_
9089
@@ -146,6 +145,9 @@ def cfn_handler(event: events.CloudFormationCustomResourceEvent, context: Lambda
146145
if event["ResourceType"] == "Custom::SendCFNParameters":
147146
handle_metrics(event)
148147

148+
if event["ResourceType"] == "Custom::CheckServiceLinkedRole":
149+
response_data = check_service_linked_role(event)
150+
149151
logger.info("Completed successfully, sending response to cfn")
150152
except Exception as err:
151153
log_message["EXCEPTION"] = str(err)
@@ -284,6 +286,36 @@ def handle_metrics(event: events.CloudFormationCustomResourceEvent):
284286
logger.warning(str(err))
285287

286288

289+
def check_service_linked_role(event: events.CloudFormationCustomResourceEvent):
290+
"""Handles checking if service linked role exist
291+
292+
Args:
293+
event (dict): event from CloudFormation on create, update or delete
294+
295+
Returns:
296+
dict: service linked role status
297+
298+
{
299+
ServiceLinkedRoleExist: boolean
300+
}
301+
"""
302+
response = {}
303+
iam_client = boto3.client("iam")
304+
if event["RequestType"] == "Create" or event["RequestType"] == "Update":
305+
try:
306+
service_linked_role = iam_client.get_role(RoleName='AWSServiceRoleForVPCTransitGateway')
307+
logger.info(service_linked_role)
308+
response = {"ServiceLinkedRoleExist": "True"}
309+
except ClientError as e:
310+
logger.exception('%s', e)
311+
if e.response['Error']['Code'] == 'NoSuchEntity':
312+
response = {"ServiceLinkedRoleExist": "False"}
313+
else:
314+
raise e
315+
logger.debug(response)
316+
return response
317+
318+
287319
def send(
288320
event: events.CloudFormationCustomResourceEvent,
289321
context: LambdaContext,
@@ -336,4 +368,4 @@ def send(
336368
except error.URLError as e:
337369
# Handle URL errors (e.g., connectivity issues, invalid URL)
338370
logger.error("send(..) failed sending PUT request: %s", str(e.reason))
339-
raise
371+
raise

source/lambda/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "network-orchestration-for-tgw"
7-
version = "3.3.8-dev"
7+
version = "3.3.11"
88
description = "solution packages for network-orchestration-for-tgw"
99
requires-python = ">=3.10"
1010
license = { text = "Apache Software License" }

source/ui/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "network-orchestrator-for-aws-transit-gateway",
3-
"version": "3.3.10",
3+
"version": "3.3.11",
44
"description": "Network Orchestration for AWS Transit Gateway(SO0058)",
55
"license": "Apache-2.0",
66
"author": {

0 commit comments

Comments
 (0)