How to encrypt sns topic at rest to avoid cloud alters - json

Currently sns topics are getting generated from an ansible script, below is the snippet where I think it is getting generated.
Resources:
NotificaionTopic:
Type: "AWS::SNS::Topic"
Properties:
Subscription:
- Endpoint: xxxx#test.com
protocol: email
I need to encrypt the sns topics, can you please let me what changes I need to make so that it will start encrypting sns topics.
Any help is much appreciated.

If you provide a KmsMasterKeyId to the resource, the service will encrypt the topic.
Type: AWS::SNS::Topic
Properties:
ContentBasedDeduplication: Boolean
DisplayName: String
KmsMasterKeyId: String
Subscription:
- Subscription
Tags:
- Tag
TopicName: String
See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html

Related

Selecting specific JSON fields to use in SNS message

I'm trying to build a step function which receives json as input and then uses only some of this JSON in a message sent via SNS in the step function. I've tried using some of the instrinsic json manipulation functions available but with no luck.
Is there a way to extract specific json fields for an SNS message without using a lambda?
For the message field, I would like the it to be:
message.$: $.name $.questions etc...
But this doesn't work
Here is my code:
stepFunctions:
stateMachines:
hellostepfunc1:
name: test
definition:
Comment: "test"
StartAt: SNSState
States:
SNSState:
Type: Task
InputPath: $
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn:
Fn::GetAtt: [ MyTopic, TopicArn ]
Message.$: $ //here I would like to send multiple e.g $.name $questions
End: true
The best way is to use an AWS Lambda function. That is, develop a custom AWS Lambda function that can read and manipulate JSON to meet your business requirments using a JSON library. Then hook these Lambda functions into an Amazon States Language document.

Meraki group policy deployment using API via Ansible uri module

I am trying to create a Meraki group policy via API using Ansible. When running the ansible-playbook, I get "New group policies must have a name" error message. Name is added in the json files.
Can you please check the json and playbook files and help and sorting this issue.
Many Thanks.
Playbook.yml
- name: Group Policy via API
hosts: localhost
gather_facts: no
tasks:
- name: Deploy Group Policy
uri:
url: https://api.meraki.com/api/v1/networks/xxxxxxxxxxxxxxxxxxx/groupPolicies
method: POST
return_content: yes
headers:
X-Cisco-Meraki-API-Key:xxxxxxxxxxxxxxxxxxxxxxxxxxx
body_format: json
body: "{{ lookup('ansible.builtin.file','create_body_4.json') | to_json }}"
create_body.json
{
"name": "test01"
}
I have also tried the RequestBody(JSON) from the Meraki example (https://developer.cisco.com/meraki/api-v1/#!create-network-group-policy) but still get the same error message. It seems like "create_body.json" file is not in correct format hence "name" is not parsed properly.
Many thanks.
Issue Resolved:
Removed | "to_json" from body as file was already in json
Correct format is
body: "{{ lookup('ansible.builtin.file','create_body_4.json')

Does Artillery support html methods other that GET and POST?

I'm trying to develop scenarios for load testing an application with Artillery. The application in question uses the GET, POST, PUT, and DELETE html methods, but all of the available documentation I've been able to find only discusses the get: and post: keywords (under scenarios: - flow:) which I assume would use the GET and POST methods. At least two sources I've found, including one at artillery.io, imply that PUT, PATCH, and DELETE are supported, but then provide no information on how to specify the http method on an http request. Can someone advise how to specify PUT and DELETE requests in an Artillery scenario?
(By the way, there are at least 10 other html methods besides the 5 mentioned here.)
PUT and DELETE will follow similar patterns as GET / POST
config:
target: "https://example.com"
phases:
- duration: 10
arrivalRate: 1
scenarios:
- flow:
- delete:
url: "/users/12345"
- put:
url: "/users/12345"
json:
firstName: "hello world"
lastName: "Huh!"

Add custom params to prometheus scrape request

We have metrics endpoint enabled in our application to get metrics. It requires custom parameter, how to configure prometheus.yaml to send custom param as part of each metrics scrape
Below is my prometheus.yml configuration
# Sample METRICS
- job_name: 'sys-metrics'
metrics_path: '/sys/metrics'
# Optional HTTP URL parameters.
params:
-user-id: ['myemail#email.com']
scrape_interval: 3s
static_configs:
- targets: ['dev.devhost.domain.com:12345']
When I start server, I get marshal error
parsing YAML file prometheus.yml: yaml: unmarshal errors:\n line 37: field -user-id not found in type config.plain"
Any help appreciated
under params, user-id is child element, add tab to resolve. as I defined at same level, prometheus expected to be one of pre-defined config.
params:
-user-id: ['myemail#email.com']
Issue solved

Cumulocity JSON via MQTT / measurement and error topic

I'm trying to send measurement values to my Cumulocity Tenant via JSON MQTT.
For my test connection I use MQTTBox.
I have already successfully sent data / create new deivces via MQTT.
100,MQTT-Simulation-1,c8y_MQTTdevice
211,80
I have now tried to change my format to JSON MQTT.
According to the Cumulocity IoT Guide (http://www.cumulocity.com/guides/mqtt/json/) I have defined my MQTT topic endpoint.
<api>/<resource>/<action>/<id>
measurement/measurements/create/231
Topic to publish: measurement/measurements/create/231
Payload Type: String / JSON / XML / Characters
Payload: {"c8y_Temperature": {"T": {"unit": "°C","value": 35.742410434759904}}}
As described in the guide, the payload of SmartRest can be used?
The examples in the Guide looks different as described, no ID can be found here in the topic to publish.
A subscription to the topic error is also not possible. Only to the topic smartrest error s/e.
JSON via MQTT will only be possible in the next release for my main tenant - cumulocity support.