Skip to content

Commit d23f209

Browse files
committed
address comment
1 parent b876370 commit d23f209

4 files changed

Lines changed: 41 additions & 17 deletions

File tree

integration/combination/test_function_with_capacity_provider.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ def test_function_with_capacity_provider_custom_role(self):
4040

4141
def test_function_with_capacity_provider_default_role(self):
4242
"""Test Lambda function with CapacityProviderConfig using default operator role.
43-
44-
Note: This test is skipped until 12/01/2024 because the managed policy required for
45-
the default operator role is not available until then.
4643
"""
4744
# Phase 1: Prepare parameters from companion stack
4845
parameters = [
@@ -59,7 +56,7 @@ def test_function_with_capacity_provider_default_role(self):
5956
self.assertEqual(len(lambda_resources), 1, "Should create exactly one Lambda function")
6057

6158
capacity_provider_resources = self.get_stack_resources("AWS::Lambda::CapacityProvider")
62-
self.assertEqual(len(capacity_provider_resources), 1, "Should create exactly one CapacityProvider")
59+
self.assertEqual(len(capacity_provider_resources), 2, "Should create exactly two CapacityProviders")
6360

6461
iam_role_resources = self.get_stack_resources("AWS::IAM::Role")
65-
self.assertEqual(len(iam_role_resources), 2, "Should create exactly two IAM roles")
62+
self.assertEqual(len(iam_role_resources), 3, "Should create exactly three IAM roles")

integration/resources/expected/combination/function_lmi_default.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
[
22
{
3-
"LogicalResourceId": "MyCapacityProvider",
3+
"LogicalResourceId": "SimpleCapacityProvider",
44
"ResourceType": "AWS::Lambda::CapacityProvider"
55
},
66
{
7-
"LogicalResourceId": "MyCapacityProviderOperatorRole",
7+
"LogicalResourceId": "SimpleCapacityProviderOperatorRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
},
10+
{
11+
"LogicalResourceId": "AdvancedCapacityProvider",
12+
"ResourceType": "AWS::Lambda::CapacityProvider"
13+
},
14+
{
15+
"LogicalResourceId": "AdvancedCapacityProviderOperatorRole",
816
"ResourceType": "AWS::IAM::Role"
917
},
1018
{

integration/resources/templates/combination/function_lmi_custom.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ Resources:
2424
Statement:
2525
- Effect: Allow
2626
Action:
27-
- ec2:TerminateInstances
2827
- ec2:AttachNetworkInterface
29-
- ec2:RunInstances
3028
- ec2:CreateTags
29+
- ec2:RunInstances
3130
Resource:
3231
- !Sub arn:${AWS::Partition}:ec2:*:*:instance/*
3332
- !Sub arn:${AWS::Partition}:ec2:*:*:network-interface/*
@@ -39,12 +38,12 @@ Resources:
3938
Action:
4039
- ec2:DescribeAvailabilityZones
4140
- ec2:DescribeCapacityReservations
42-
- ec2:DescribeInstanceTypes
41+
- ec2:DescribeInstances
42+
- ec2:DescribeInstanceStatus
4343
- ec2:DescribeInstanceTypeOfferings
44+
- ec2:DescribeInstanceTypes
4445
- ec2:DescribeSecurityGroups
4546
- ec2:DescribeSubnets
46-
- ec2:DescribeInstances
47-
- ec2:DescribeInstanceStatus
4847
Resource: '*'
4948
- Effect: Allow
5049
Action:
@@ -72,7 +71,6 @@ Resources:
7271
SecurityGroupIds:
7372
- !Ref SecurityGroup
7473
OperatorRole: !GetAtt MyCapacityProviderCustomRole.Arn
75-
KmsKeyArn: !Ref KMSKeyArn
7674

7775
MyFunction:
7876
Type: AWS::Serverless::Function

integration/resources/templates/combination/function_lmi_default.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ Parameters:
77
Type: String
88

99
Resources:
10-
MyCapacityProvider:
10+
SimpleCapacityProvider:
1111
Type: AWS::Serverless::CapacityProvider
1212
Properties:
13-
CapacityProviderName: !Sub "${AWS::StackName}-cp"
1413
VpcConfig:
1514
SubnetIds:
1615
- !Ref SubnetId
1716
SecurityGroupIds:
1817
- !Ref SecurityGroup
19-
KmsKeyArn: !Ref KMSKeyArn
2018

2119
MyFunction:
2220
Type: AWS::Serverless::Function
@@ -25,7 +23,30 @@ Resources:
2523
Handler: index.handler
2624
CodeUri: ${codeuri}
2725
CapacityProviderConfig:
28-
Arn: !GetAtt MyCapacityProvider.Arn
26+
Arn: !GetAtt SimpleCapacityProvider.Arn
27+
28+
AdvancedCapacityProvider:
29+
Type: AWS::Serverless::CapacityProvider
30+
Properties:
31+
CapacityProviderName: !Sub "${AWS::StackName}-cp"
32+
VpcConfig:
33+
SubnetIds:
34+
- !Ref SubnetId
35+
SecurityGroupIds:
36+
- !Ref SecurityGroup
37+
InstanceRequirements:
38+
Architectures:
39+
- x86_64
40+
AllowedTypes:
41+
- m5.large
42+
- m5.xlarge
43+
- m5.2xlarge
44+
ScalingConfig:
45+
MaxVCpuCount: 64
46+
AverageCPUUtilization: 70
47+
KmsKeyArn: !Ref KMSKeyArn
48+
Tags:
49+
Environment: Test
2950

3051
Metadata:
3152
SamTransformTest: true

0 commit comments

Comments
 (0)