Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iot): configure IoT Logging #31352

Merged
merged 11 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add integ test
  • Loading branch information
badmintoncryer committed Sep 7, 2024
commit c4c52948a1f249a8a2ba19a5418e068883d7e4ab
9 changes: 5 additions & 4 deletions packages/@aws-cdk/aws-iot-alpha/lib/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
*/
export interface ILogging extends IResource {
/**
* The log ID
* @attribute
*/
readonly logId: string;
Expand Down Expand Up @@ -61,9 +62,9 @@ export class Logging extends Resource implements ILogging {
* @param id The construct's name.
* @param logId AWS IoT Logging ID
*/
public static fromLogId(scope: Construct, id: string, logid: string): ILogging {
public static fromLogId(scope: Construct, id: string, logId: string): ILogging {
class Import extends Resource implements ILogging {
public readonly logId = logid;
public readonly logId = logId;
}
return new Import(scope, id);
}
Expand All @@ -74,7 +75,7 @@ export class Logging extends Resource implements ILogging {
*/
public readonly logId: string;

constructor(scope: Construct, id: string, props: LoggingProps) {
constructor(scope: Construct, id: string, props?: LoggingProps) {
super(scope, id);

const accountId = Stack.of(this).account;
Expand Down Expand Up @@ -114,7 +115,7 @@ export class Logging extends Resource implements ILogging {

const resource = new iot.CfnLogging(this, 'Resource', {
accountId,
defaultLogLevel: props.logLevel ?? LogLevel.ERROR,
defaultLogLevel: props?.logLevel ?? LogLevel.ERROR,
roleArn: role.roleArn,
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"Resources": {
"LoggingRoleF8CB8FA1": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "iot.amazonaws.com"
}
}
],
"Version": "2012-10-17"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"iot:DeleteV2LoggingLevel",
"iot:GetLoggingOptions",
"iot:GetV2LoggingOptions",
"iot:ListV2LoggingLevels",
"iot:SetLoggingOptions",
"iot:SetV2LoggingLevel",
"iot:SetV2LoggingOptions",
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:PutMetricFilter",
"logs:PutRetentionPolicy"
],
"Effect": "Allow",
"Resource": {
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":logs:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":log-group:AWSIotLogsV2:*"
]
]
}
}
],
"Version": "2012-10-17"
},
"PolicyName": "LoggingPolicy"
}
]
}
},
"Logging019093B9": {
"Type": "AWS::IoT::Logging",
"Properties": {
"AccountId": {
"Ref": "AWS::AccountId"
},
"DefaultLogLevel": "DEBUG",
"RoleArn": {
"Fn::GetAtt": [
"LoggingRoleF8CB8FA1",
"Arn"
]
}
}
}
},
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading