Skip to content

Commit 394bc04

Browse files
authored
Merge branch 'master' into fix-17463
2 parents 4710cba + e2f6918 commit 394bc04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+7970
-157
lines changed

.mergify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pull_request_rules:
1010
label:
1111
add: [ contribution/core ]
1212
conditions:
13-
- author~=^(eladb|RomainMuller|garnaat|nija-at|skinny85|rix0rrr|NGL321|Jerry-AWS|MrArnoldPalmer|NetaNir|iliapolo|njlynch|ericzbeard|ccfife|fulghum|pkandasamy91|SoManyHs|uttarasridhar|otaviomacedo|BenChaimberg|madeline-k|BryanPan342|kaizen3031593|comcalvi|Chriscbr|corymhall|peterwoodworth|ryparker)$
13+
- author~=^(eladb|RomainMuller|garnaat|nija-at|skinny85|rix0rrr|NGL321|Jerry-AWS|MrArnoldPalmer|NetaNir|iliapolo|njlynch|ericzbeard|ccfife|fulghum|pkandasamy91|SoManyHs|uttarasridhar|otaviomacedo|BenChaimberg|madeline-k|BryanPan342|kaizen3031593|comcalvi|Chriscbr|corymhall|peterwoodworth|ryparker|TheRealAmazonKendra)$
1414
- -label~="contribution/core"
1515
- name: automatic merge
1616
actions:

packages/@aws-cdk/aws-eks/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,24 @@ cluster.addHelmChart('test-chart', {
11441144
});
11451145
```
11461146

1147+
### OCI Charts
1148+
1149+
OCI charts are also supported.
1150+
Also replace the `${VARS}` with appropriate values.
1151+
1152+
```ts
1153+
declare const cluster: eks.Cluster;
1154+
// option 1: use a construct
1155+
new eks.HelmChart(this, 'MyOCIChart', {
1156+
cluster,
1157+
chart: 'some-chart',
1158+
repository: 'oci://${ACCOUNT_ID}.dkr.ecr.${ACCOUNT_REGION}.amazonaws.com/${REPO_NAME}',
1159+
namespace: 'oci',
1160+
version: '0.0.1'
1161+
});
1162+
1163+
```
1164+
11471165
Helm charts are implemented as CloudFormation resources in CDK.
11481166
This means that if the chart is deleted from your code (or the stack is
11491167
deleted), the next `cdk deploy` will issue a `helm uninstall` command and the

packages/@aws-cdk/aws-eks/lib/kubectl-handler/helm/__init__.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import json
22
import logging
33
import os
4+
import re
45
import subprocess
56
import shutil
7+
import tempfile
68
import zipfile
79
from urllib.parse import urlparse, unquote
810

@@ -78,13 +80,71 @@ def helm_handler(event, context):
7880
# future work: support versions from s3 assets
7981
chart = get_chart_asset_from_url(chart_asset_url)
8082

83+
if repository.startswith('oci://'):
84+
assert(repository is not None)
85+
tmpdir = tempfile.TemporaryDirectory()
86+
chart_dir = get_chart_from_oci(tmpdir.name, release, repository, version)
87+
chart = chart_dir
88+
8189
helm('upgrade', release, chart, repository, values_file, namespace, version, wait, timeout, create_namespace)
8290
elif request_type == "Delete":
8391
try:
8492
helm('uninstall', release, namespace=namespace, timeout=timeout)
8593
except Exception as e:
8694
logger.info("delete error: %s" % e)
8795

96+
97+
def get_oci_cmd(repository, version):
98+
99+
cmnd = []
100+
pattern = '\d+.dkr.ecr.[a-z]+-[a-z]+-\d.amazonaws.com'
101+
102+
registry = repository.rsplit('/', 1)[0].replace('oci://', '')
103+
104+
if re.fullmatch(pattern, registry) is not None:
105+
region = registry.replace('.amazonaws.com', '').split('.')[-1]
106+
cmnd = [
107+
f"aws ecr get-login-password --region {region} | " \
108+
f"helm registry login --username AWS --password-stdin {registry}; helm pull {repository} --version {version} --untar"
109+
]
110+
else:
111+
logger.info("Non AWS OCI repository found")
112+
cmnd = ['HELM_EXPERIMENTAL_OCI=1', 'helm', 'pull', repository, '--version', version, '--untar']
113+
114+
return cmnd
115+
116+
117+
def get_chart_from_oci(tmpdir, release, repository = None, version = None):
118+
119+
cmnd = get_oci_cmd(repository, version)
120+
121+
maxAttempts = 3
122+
retry = maxAttempts
123+
while retry > 0:
124+
try:
125+
logger.info(cmnd)
126+
env = get_env_with_oci_flag()
127+
output = subprocess.check_output(cmnd, stderr=subprocess.STDOUT, cwd=tmpdir, env=env, shell=True)
128+
logger.info(output)
129+
130+
return os.path.join(tmpdir, release)
131+
except subprocess.CalledProcessError as exc:
132+
output = exc.output
133+
if b'Broken pipe' in output:
134+
retry = retry - 1
135+
logger.info("Broken pipe, retries left: %s" % retry)
136+
else:
137+
raise Exception(output)
138+
raise Exception(f'Operation failed after {maxAttempts} attempts: {output}')
139+
140+
141+
def get_env_with_oci_flag():
142+
env = os.environ.copy()
143+
env['HELM_EXPERIMENTAL_OCI'] = '1'
144+
145+
return env
146+
147+
88148
def helm(verb, release, chart = None, repo = None, file = None, namespace = None, version = None, wait = False, timeout = None, create_namespace = None):
89149
import subprocess
90150

@@ -113,7 +173,8 @@ def helm(verb, release, chart = None, repo = None, file = None, namespace = None
113173
retry = maxAttempts
114174
while retry > 0:
115175
try:
116-
output = subprocess.check_output(cmnd, stderr=subprocess.STDOUT, cwd=outdir)
176+
env = get_env_with_oci_flag()
177+
output = subprocess.check_output(cmnd, stderr=subprocess.STDOUT, cwd=outdir, env=env)
117178
logger.info(output)
118179
return
119180
except subprocess.CalledProcessError as exc:

packages/@aws-cdk/aws-eks/lib/kubectl-provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ export class KubectlProvider extends NestedStack implements IKubectlProvider {
168168
resources: [cluster.clusterArn],
169169
}));
170170

171+
// For OCI helm chart authorization.
172+
this.handlerRole.addManagedPolicy(
173+
iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonEC2ContainerRegistryReadOnly'),
174+
);
175+
171176
// allow this handler to assume the kubectl role
172177
cluster.kubectlRole.grant(this.handlerRole, 'sts:AssumeRole');
173178

packages/@aws-cdk/aws-eks/test/cluster.test.ts

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,41 @@ describe('cluster', () => {
21072107
],
21082108
});
21092109

2110-
2110+
Template.fromStack(providerStack).hasResourceProperties('AWS::IAM::Role', {
2111+
AssumeRolePolicyDocument: {
2112+
Statement: [
2113+
{
2114+
Action: 'sts:AssumeRole',
2115+
Effect: 'Allow',
2116+
Principal: { Service: 'lambda.amazonaws.com' },
2117+
},
2118+
],
2119+
Version: '2012-10-17',
2120+
},
2121+
ManagedPolicyArns: [
2122+
{
2123+
'Fn::Join': ['', [
2124+
'arn:',
2125+
{ Ref: 'AWS::Partition' },
2126+
':iam::aws:policy/service-role/AWSLambdaBasicExecutionRole',
2127+
]],
2128+
},
2129+
{
2130+
'Fn::Join': ['', [
2131+
'arn:',
2132+
{ Ref: 'AWS::Partition' },
2133+
':iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole',
2134+
]],
2135+
},
2136+
{
2137+
'Fn::Join': ['', [
2138+
'arn:',
2139+
{ Ref: 'AWS::Partition' },
2140+
':iam::aws:policy/AmazonEC2ContainerRegistryReadOnly',
2141+
]],
2142+
},
2143+
],
2144+
});
21112145
});
21122146

21132147
test('coreDnsComputeType will patch the coreDNS configuration to use a "fargate" compute type and restore to "ec2" upon removal', () => {
@@ -2274,8 +2308,42 @@ describe('cluster', () => {
22742308
},
22752309
});
22762310

2311+
Template.fromStack(providerStack).hasResourceProperties('AWS::IAM::Role', {
2312+
AssumeRolePolicyDocument: {
2313+
Statement: [
2314+
{
2315+
Action: 'sts:AssumeRole',
2316+
Effect: 'Allow',
2317+
Principal: { Service: 'lambda.amazonaws.com' },
2318+
},
2319+
],
2320+
Version: '2012-10-17',
2321+
},
2322+
ManagedPolicyArns: [
2323+
{
2324+
'Fn::Join': ['', [
2325+
'arn:',
2326+
{ Ref: 'AWS::Partition' },
2327+
':iam::aws:policy/service-role/AWSLambdaBasicExecutionRole',
2328+
]],
2329+
},
2330+
{
2331+
'Fn::Join': ['', [
2332+
'arn:',
2333+
{ Ref: 'AWS::Partition' },
2334+
':iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole',
2335+
]],
2336+
},
2337+
{
2338+
'Fn::Join': ['', [
2339+
'arn:',
2340+
{ Ref: 'AWS::Partition' },
2341+
':iam::aws:policy/AmazonEC2ContainerRegistryReadOnly',
2342+
]],
2343+
},
2344+
],
2345+
});
22772346
});
2278-
22792347
});
22802348

22812349
test('kubectl provider passes security group to provider', () => {

packages/@aws-cdk/cfnspec/spec-source/cfn-docs/cfn-docs.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11527,7 +11527,7 @@
1152711527
"description": "Specifies a VPC flow log that captures IP traffic for a specified network interface, subnet, or VPC. To view the log data, use Amazon CloudWatch Logs (CloudWatch Logs) to help troubleshoot connection issues. For example, you can use a flow log to investigate why certain traffic isn't reaching an instance, which can help you diagnose overly restrictive security group rules. For more information, see [VPC Flow Logs](https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html) in the *Amazon VPC User Guide* .",
1152811528
"properties": {
1152911529
"DeliverLogsPermissionArn": "The ARN for the IAM role that permits Amazon EC2 to publish flow logs to a CloudWatch Logs log group in your account.\n\nIf you specify `LogDestinationType` as `s3` , do not specify `DeliverLogsPermissionArn` or `LogGroupName` .",
11530-
"DestinationOptions": "The destination options.",
11530+
"DestinationOptions": "The destination options. The following options are supported:\n\n- `FileFormat` - The format for the flow log ( `plain-text` | `parquet` ). The default is `plain-text` .\n- `HiveCompatiblePartitions` - Indicates whether to use Hive-compatible prefixes for flow logs stored in Amazon S3 ( `true` | `false` ). The default is `false` .\n- `PerHourPartition` - Indicates whether to partition the flow log per hour ( `true` | `false` ). The default is `false` .",
1153111531
"LogDestination": "The destination to which the flow log data is to be published. Flow log data can be published to a CloudWatch Logs log group or an Amazon S3 bucket. The value specified for this parameter depends on the value specified for `LogDestinationType` .\n\nIf `LogDestinationType` is not specified or `cloud-watch-logs` , specify the Amazon Resource Name (ARN) of the CloudWatch Logs log group. For example, to publish to a log group called `my-logs` , specify `arn:aws:logs:us-east-1:123456789012:log-group:my-logs` . Alternatively, use `LogGroupName` instead.\n\nIf LogDestinationType is `s3` , specify the ARN of the Amazon S3 bucket. You can also specify a subfolder in the bucket. To specify a subfolder in the bucket, use the following ARN format: `bucket_ARN/subfolder_name/` . For example, to specify a subfolder named `my-logs` in a bucket named `my-bucket` , use the following ARN: `arn:aws:s3:::my-bucket/my-logs/` . You cannot use `AWSLogs` as a subfolder name. This is a reserved term.",
1153211532
"LogDestinationType": "The type of destination to which the flow log data is to be published. Flow log data can be published to CloudWatch Logs or Amazon S3. To publish flow log data to CloudWatch Logs, specify `cloud-watch-logs` . To publish flow log data to Amazon S3, specify `s3` .\n\nIf you specify `LogDestinationType` as `s3` , do not specify `DeliverLogsPermissionArn` or `LogGroupName` .\n\nDefault: `cloud-watch-logs`",
1153311533
"LogFormat": "The fields to include in the flow log record, in the order in which they should appear. For a list of available fields, see [Flow Log Records](https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-log-records) . If you omit this parameter, the flow log is created using the default format. If you specify this parameter, you must specify at least one field.\n\nSpecify the fields using the `${field-id}` format, separated by spaces.",
@@ -12312,7 +12312,7 @@
1231212312
"Ref": "`Ref` returns the ID of the network insights scope.",
1231312313
"UpdatedDate": "The last updated date."
1231412314
},
12315-
"description": "Describes a Network Access Scope.",
12315+
"description": "Describes a Network Access Scope. A Network Access Scope defines outbound (egress) and inbound (ingress) traffic patterns, including sources, destinations, paths, and traffic types.\n\nNetwork Access Analyzer identifies unintended network access to your resources on AWS . When you start an analysis on a Network Access Scope, Network Access Analyzer produces findings. For more information, see the [Network Access Analyzer User Guide](https://docs.aws.amazon.com/vpc/latest/network-access-analyzer/) .",
1231612316
"properties": {
1231712317
"ExcludePaths": "The paths to exclude.",
1231812318
"MatchPaths": "The paths to match.",
@@ -22316,8 +22316,9 @@
2231622316
},
2231722317
"AWS::IoTSiteWise::Asset": {
2231822318
"attributes": {
22319-
"AssetId": "",
22320-
"Ref": "`Ref` returns the `AssetId` ."
22319+
"AssetArn": "The ARN of the asset.",
22320+
"AssetId": "The ID of the asset.",
22321+
"Ref": "`Ref` returns `AssetId` and `AssetArn` ."
2232122322
},
2232222323
"description": "Creates an asset from an existing asset model. For more information, see [Creating assets](https://docs.aws.amazon.com/iot-sitewise/latest/userguide/create-assets.html) in the *AWS IoT SiteWise User Guide* .",
2232322324
"properties": {
@@ -22445,7 +22446,7 @@
2244522446
"description": "Contains a tumbling window, which is a repeating fixed-sized, non-overlapping, and contiguous time window. You can use this window in metrics to aggregate data from properties and other assets.\n\nYou can use `m` , `h` , `d` , and `w` when you specify an interval or offset. Note that `m` represents minutes, `h` represents hours, `d` represents days, and `w` represents weeks. You can also use `s` to represent seconds in `offset` .\n\nThe `interval` and `offset` parameters support the [ISO 8601 format](https://docs.aws.amazon.com/https://en.wikipedia.org/wiki/ISO_8601) . For example, `PT5S` represents 5 seconds, `PT5M` represents 5 minutes, and `PT5H` represents 5 hours.",
2244622447
"properties": {
2244722448
"Interval": "The time interval for the tumbling window. The interval time must be between 1 minute and 1 week.\n\nAWS IoT SiteWise computes the `1w` interval the end of Sunday at midnight each week (UTC), the `1d` interval at the end of each day at midnight (UTC), the `1h` interval at the end of each hour, and so on.\n\nWhen AWS IoT SiteWise aggregates data points for metric computations, the start of each interval is exclusive and the end of each interval is inclusive. AWS IoT SiteWise places the computed data point at the end of the interval.",
22448-
"Offset": ""
22449+
"Offset": "The offset for the tumbling window. The `offset` parameter accepts the following:\n\n- The offset time.\n\nFor example, if you specify `18h` for `offset` and `1d` for `interval` , AWS IoT SiteWise aggregates data in one of the following ways:\n\n- If you create the metric before or at 6 PM (UTC), you get the first aggregation result at 6 PM (UTC) on the day when you create the metric.\n- If you create the metric after 6 PM (UTC), you get the first aggregation result at 6 PM (UTC) the next day.\n- The ISO 8601 format.\n\nFor example, if you specify `PT18H` for `offset` and `1d` for `interval` , AWS IoT SiteWise aggregates data in one of the following ways:\n\n- If you create the metric before or at 6 PM (UTC), you get the first aggregation result at 6 PM (UTC) on the day when you create the metric.\n- If you create the metric after 6 PM (UTC), you get the first aggregation result at 6 PM (UTC) the next day.\n- The 24-hour clock.\n\nFor example, if you specify `00:03:00` for `offset` , `5m` for `interval` , and you create the metric at 2 PM (UTC), you get the first aggregation result at 2:03 PM (UTC). You get the second aggregation result at 2:08 PM (UTC).\n- The offset time zone.\n\nFor example, if you specify `2021-07-23T18:00-08` for `offset` and `1d` for `interval` , AWS IoT SiteWise aggregates data in one of the following ways:\n\n- If you create the metric before or at 6 PM (PST), you get the first aggregation result at 6 PM (PST) on the day when you create the metric.\n- If you create the metric after 6 PM (PST), you get the first aggregation result at 6 PM (PST) the next day."
2244922450
}
2245022451
},
2245122452
"AWS::IoTSiteWise::AssetModel.VariableValue": {
@@ -22497,7 +22498,7 @@
2249722498
"description": "Contains a gateway's platform information.",
2249822499
"properties": {
2249922500
"Greengrass": "A gateway that runs on AWS IoT Greengrass .",
22500-
"GreengrassV2": ""
22501+
"GreengrassV2": "A gateway that runs on AWS IoT Greengrass V2."
2250122502
}
2250222503
},
2250322504
"AWS::IoTSiteWise::Gateway.Greengrass": {
@@ -22509,9 +22510,9 @@
2250922510
},
2251022511
"AWS::IoTSiteWise::Gateway.GreengrassV2": {
2251122512
"attributes": {},
22512-
"description": "",
22513+
"description": "Contains details for a gateway that runs on AWS IoT Greengrass V2. To create a gateway that runs on AWS IoT Greengrass V2, you must deploy the IoT SiteWise Edge component to your gateway device. Your [Greengrass device role](https://docs.aws.amazon.com/greengrass/v2/developerguide/device-service-role.html) must use the `AWSIoTSiteWiseEdgeAccess` policy. For more information, see [Using AWS IoT SiteWise at the edge](https://docs.aws.amazon.com/iot-sitewise/latest/userguide/sw-gateways.html) in the *AWS IoT SiteWise User Guide* .",
2251322514
"properties": {
22514-
"CoreDeviceThingName": ""
22515+
"CoreDeviceThingName": "The name of the AWS IoT thing for your AWS IoT Greengrass V2 core device."
2251522516
}
2251622517
},
2251722518
"AWS::IoTSiteWise::Portal": {
@@ -22542,7 +22543,7 @@
2254222543
},
2254322544
"description": "Creates a project in the specified portal.\n\n> Make sure that the project name and description don't contain confidential information.",
2254422545
"properties": {
22545-
"AssetIds": "",
22546+
"AssetIds": "A list that contains the IDs of each asset associated with the project.",
2254622547
"PortalId": "The ID of the portal in which to create the project.",
2254722548
"ProjectDescription": "A description for the project.",
2254822549
"ProjectName": "A friendly name for the project.",
@@ -32195,7 +32196,7 @@
3219532196
"Permissions": "A list of resource permissions on the data source.",
3219632197
"SslProperties": "Secure Socket Layer (SSL) properties that apply when Amazon QuickSight connects to your underlying source.",
3219732198
"Tags": "Contains a map of the key-value pairs for the resource tag or tags assigned to the data source.",
32198-
"Type": "The type of the data source. To return a list of all data sources, use `ListDataSources` .\n\nUse `AMAZON_ELASTICSEARCH` for Amazon OpenSearch Service.",
32199+
"Type": "The type of the data source. To return a list of all data sources, use `ListDataSources` .\n\nUse `AMAZON_ELASTICSEARCH` for Amazon OpenSearch Service .",
3219932200
"VpcConnectionProperties": "Use this parameter only when you want Amazon QuickSight to use a VPC connection when connecting to your underlying source."
3220032201
}
3220132202
},

packages/@aws-cdk/cloudformation-diff/lib/format-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as chalk from 'chalk';
2-
import * as stringWidth from 'string-width';
2+
import stringWidth from 'string-width';
33
import * as table from 'table';
44

55
/**

packages/@aws-cdk/cloudformation-diff/lib/iam/statement.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import * as deepEqual from 'fast-deep-equal';
21
import { deepRemoveUndefined } from '../util';
32

3+
// namespace object imports won't work in the bundle for function exports
4+
// eslint-disable-next-line @typescript-eslint/no-require-imports
5+
const deepEqual = require('fast-deep-equal');
6+
47
export class Statement {
58
/**
69
* Statement ID

packages/aws-cdk/NOTICE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
11
AWS Cloud Development Kit (AWS CDK)
22
Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
Third party attributions of this package can be found in the THIRD_PARTY_LICENSES file

0 commit comments

Comments
 (0)