Skip to content
This repository was archived by the owner on Mar 27, 2022. It is now read-only.

Commit 04e72fa

Browse files
committed
Correcting id for user and group deletion
1 parent 6971216 commit 04e72fa

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lambda-aws-sso-google-sync"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
authors = ["Marc Mettke <marc@itmettke.de>"]
55
edition = "2021"
66
description = "Syncs Users and Groups from Google Workspace to AWS SSO"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ them either with the Event that is send to the lambda, or via environment variab
7070
```json
7171
{
7272
"security_hub_google_creds": {
73-
"region": "eu-central-1",
73+
"region": "<region_of_secret>",
7474
"id": "<google_secret_name>"
7575
},
7676
"security_hub_scim_creds": {
77-
"region": "eu-central-1",
77+
"region": "<region_of_secret>",
7878
"id": "<scim_secret_name>"
7979
},
8080
// Optional, remove if not required. Example: `email:aws-*`
@@ -105,8 +105,8 @@ them either with the Event that is send to the lambda, or via environment variab
105105

106106
### Environment Variables
107107
```sh
108-
SH_GOOGLE_CREDS="{\"region\": \"eu-central-1\",\"id\": \"<google_secret_name>\"}"
109-
SH_SCIM_CREDS="{\"region\": \"eu-central-1\",\"id\": \"<scim_secret_name>\"}"
108+
SH_GOOGLE_CREDS="{\"region\": \"<region_of_secret>\",\"id\": \"<google_secret_name>\"}"
109+
SH_SCIM_CREDS="{\"region\": \"<region_of_secret>\",\"id\": \"<scim_secret_name>\"}"
110110
# Optional, skip if not required. Example: `email:aws-*`
111111
# Query send via Google API to filter users
112112
# More Infos at https://developers.google.com/admin-sdk/directory/v1/guides/search-users

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@
5959
//! * Create a CloudWatch Event to trigger the lambda regularly
6060
//!
6161
//! # Parameters
62-
//!
63-
//! The lambda function requires a few parameters to correctly work. You can define
62+
//!
63+
//! The lambda function requires a few parameters to correctly work. You can define
6464
//! them either with the Event that is send to the lambda, or via environment variables.
65-
//!
65+
//!
6666
//! ## Event
67-
//!
67+
//!
6868
//! ```json
6969
//! {
7070
//! "security_hub_google_creds": {
@@ -100,7 +100,7 @@
100100
//! "sync_strategie": [],
101101
//! }
102102
//! ```
103-
//!
103+
//!
104104
//! ## Environment Variables
105105
//! ```sh
106106
//! SH_GOOGLE_CREDS="{\"region\": \"<region_of_secret>\",\"id\": \"<google_secret_name>\"}"
@@ -132,7 +132,7 @@
132132
//! # Defines the log level
133133
//! LOG_LEVEL=""
134134
//! ```
135-
//!
135+
//!
136136
137137
#![warn(
138138
absolute_paths_not_starting_with_crate,

src/sync.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ impl<'a> SyncOp<'a> {
180180
.aws_group_lookup
181181
.iter()
182182
.filter(|(id, _)| !self.google_group_lookup.contains_key(*id))
183-
.map(|(id, u)| (id.clone(), u.display_name.clone()))
183+
.filter_map(|(id, u)| Some((id.clone(), u.display_name.clone(), u.id.as_ref()?.clone())))
184184
.collect::<Vec<_>>();
185-
for (id, display_name) in to_delete {
185+
for (id, display_name, aws_id) in to_delete {
186186
log::info!("Deleting group: {}", display_name);
187-
self.scim.delete_group(&id).await?;
187+
self.scim.delete_group(&aws_id).await?;
188188
let _ = self.aws_group_lookup.remove(&id);
189189
}
190190
Ok(())
@@ -245,11 +245,11 @@ impl<'a> SyncOp<'a> {
245245
.aws_user_lookup
246246
.iter()
247247
.filter(|(id, _)| !self.google_user_lookup.contains_key(*id))
248-
.map(|(id, u)| (id.clone(), u.user_name.clone()))
248+
.filter_map(|(id, u)| Some((id.clone(), u.user_name.clone(), u.id.as_ref()?.clone())))
249249
.collect::<Vec<_>>();
250-
for (id, user_name) in to_delete {
250+
for (id, user_name, aws_id) in to_delete {
251251
log::info!("Deleting user: {}", user_name);
252-
self.scim.delete_user(&id).await?;
252+
self.scim.delete_user(&aws_id).await?;
253253
let _ = self.aws_user_lookup.remove(&id);
254254
}
255255
Ok(())

0 commit comments

Comments
 (0)