Skip to content

Rust version of the CloudWatchAlarmSNSPayload struct/type #793

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

Closed
dacbd opened this issue Jan 24, 2024 · 3 comments · Fixed by #829
Closed

Rust version of the CloudWatchAlarmSNSPayload struct/type #793

dacbd opened this issue Jan 24, 2024 · 3 comments · Fixed by #829

Comments

@dacbd
Copy link

dacbd commented Jan 24, 2024

ref from go: https://github.com/aws/aws-lambda-go/blob/3a93ed1e265b5e368f0d20c3a2b8395d2c9f787d/events/sns.go#L34C6-L45

Maybe I'm not finding the correct struct somewhere in the SDK, but I have many cloud watch metrics alarms going to an sns topic. one of the subscribers to the topic is an lambda function.

Example:

#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::INFO)
        .with_target(false)
        .without_time()
        .init();

    run(service_fn(lambda_handler)).await
}

async fn lambda_handler(event: LambdaEvent<SnsEvent>) -> Result<(), Error> {
    info!("received events: {:?}", event.payload.records.len());
    for event in event.payload.records {
        process_record(&event)?;
    }
    Ok(())
}

fn process_record(record: &SnsRecord) -> Result<(), Error> {
    info!("processing record");
    let message = &record.sns;
    info!(message = ?message);
    /*
    I would like something to the effect of:
    let payload: CloudWatchAlarmSNSPayload = serde_json::from_str(message.message)
    */
    Ok(())
}

Or really just: SnsMessageObj<CloudWatchAlarmSNSPayload>

@calavera
Copy link
Contributor

I don't think we have those events mapped anywhere. Feel free to open a PR with struct definitions and examples.

@dacbd
Copy link
Author

dacbd commented Jan 25, 2024

@calavera I'll try to get a PR open soon.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants