I am pretty new to go and I have to use aws go sdk to read AWS Config notifications from SQS. (AWS config service -> sns -> sqs) I was able to get the message. But I want to get into the message get information like resourceType, resourceId, awsRegion. This is the sample message string(stringified json) I have. https://gist.github.com/HarishAtGitHub/fcbb01515d11044d04bde14a3d9f6e7a
I am from python background and in python it is easy to do, as the json is like a dictionary. We can easily get it by nested index. But in go it seems like I should use the right struct to understand this message.
can someone either point me to the right struct or any ideas on how to get the different properties in the message ?
I always use this tool to generate struct definitions from JSON blobs. The only thing you have to do yourself is pick a type for the null
values: it obviously can't determine those, and therefore sets them to interface{}
(any type implements this).
The struct tags (e.g. json:"changeType"
) can be omitted if you only want to unmarshal, and not the other way around.
type ConfigNotification struct {
ConfigurationItemDiff struct {
ChangedProperties struct {
} `json:"changedProperties"`
ChangeType string `json:"changeType"`
} `json:"configurationItemDiff"`
ConfigurationItem struct {
RelatedEvents []interface{} `json:"relatedEvents"`
Relationships []interface{} `json:"relationships"`
Configuration struct {
Attachments []interface{} `json:"attachments"`
AvailabilityZone string `json:"availabilityZone"`
CreateTime time.Time `json:"createTime"`
Encrypted bool `json:"encrypted"`
KmsKeyID interface{} `json:"kmsKeyId"`
Size int `json:"size"`
SnapshotID string `json:"snapshotId"`
State string `json:"state"`
VolumeID string `json:"volumeId"`
Iops int `json:"iops"`
Tags []struct {
Key string `json:"key"`
Value string `json:"value"`
} `json:"tags"`
VolumeType string `json:"volumeType"`
} `json:"configuration"`
SupplementaryConfiguration struct {
} `json:"supplementaryConfiguration"`
Tags struct {
Creator string `json:"creator"`
} `json:"tags"`
ConfigurationItemVersion string `json:"configurationItemVersion"`
ConfigurationItemCaptureTime time.Time `json:"configurationItemCaptureTime"`
ConfigurationStateID int64 `json:"configurationStateId"`
AwsAccountID string `json:"awsAccountId"`
ConfigurationItemStatus string `json:"configurationItemStatus"`
ResourceType string `json:"resourceType"`
ResourceID string `json:"resourceId"`
ResourceName interface{} `json:"resourceName"`
ARN string `json:"ARN"`
AwsRegion string `json:"awsRegion"`
AvailabilityZone string `json:"availabilityZone"`
ConfigurationStateMd5Hash string `json:"configurationStateMd5Hash"`
ResourceCreationTime time.Time `json:"resourceCreationTime"`
} `json:"configurationItem"`
NotificationCreationTime time.Time `json:"notificationCreationTime"`
MessageType string `json:"messageType"`
RecordVersion string `json:"recordVersion"`
}