Model validation failed when creatung the simplest WebACL - amazon-web-services

I bumped into this error.
Resource handler returned message: "Model validation failed (#/DefaultAction/Block/CustomResponse/ResponseCode: failed validation constraint for keyword [minimum]
)" (RequestToken: c97b2cae-821a-2be3-465a-965164d34674, HandlerErrorCode: InvalidRequest)
I am trying to make the simplest WAF for my first scratch.
const wafacl = new wafv2.CfnWebACL(this, "MyCfnWebAll",{
scope: "REGIONAL",
defaultAction: {
allow:{
customRequestHandling: {
insertHeaders: [{
name: 'name',
value: 'value',
}],
},
},
block: {
customResponse: {
responseCode: 123,
customResponseBodyKey: 'customResponseBodyKey',
responseHeaders: [{
name: 'name',
value: 'value',
}],
},
}
},
visibilityConfig:{
cloudWatchMetricsEnabled: false,
metricName: 'metricName',
sampledRequestsEnabled: false
}
});
My goal is just make the simple WAF and connect this to ALB.
Could someone help my first step?

Related

AWS Appflow flow against Salesforce is generating additional folders with flow execution ID in S3 destination bucket

I have an AWS Appflow flow against Salesforce. These are the properties:
{
description: 'salesforce_Account',
kMSArn: 'arn:aws:kms:us-west-2:<account_id>:key/e8e57dff-31ab-42c9-a997-2da88ffa3fa7',
destinationFlowConfigList: [
{
connectorType: 'S3',
destinationConnectorProperties: {
s3: {
bucketName: 'kavak-landing-raw-prod',
bucketPrefix: 'salesforce',
s3OutputFormatConfig: {
aggregationConfig: {
aggregationType: 'None',
},
fileType: 'PARQUET',
prefixConfig: {
prefixFormat: 'MONTH',
prefixType: 'PATH',
},
},
},
},
},
],
flowName: 'salesforce_Account',
sourceFlowConfig: {
connectorProfileName: 'appflow-salesforce-conn',
connectorType: 'Salesforce',
incrementalPullConfig: {
datetimeTypeFieldName: 'LastModifiedDate',
},
sourceConnectorProperties: {
salesforce: {
enableDynamicFieldUpdate: true,
includeDeletedRecords: true,
object: 'Account',
},
},
},
tasks: [
{
connectorOperator: {
salesforce: 'NO_OP',
},
sourceFields: [],
taskProperties: [
{
key: 'EXCLUDE_SOURCE_FIELDS_LIST',
value: '[]',
},
],
taskType: 'Map_all',
},
],
triggerConfig: {
triggerProperties: {
dataPullMode: 'Incremental',
scheduleExpression: 'rate(30minutes)',
},
triggerType: 'Scheduled',
},
}
The flow runs without problems, but I'm facing an issue. The issue is that, when I see the folder structure in S3 the flow is generating an additional folder before the Parquet files. These folders corresponds with the execution ID of each flow run. Here are some printscreens:
So, my question is why are these folders being created? Is it Appflow normal behavior? Or is it something related to the flow properties? I couldn't find anything in the official documentation or recent posts online regarding this issue. Can anybody help me understand this?
Thanks!

API Gateway -> SQS HTTP POST MessageAttributes

I have an API gateway setup which sends to SQS which fires a Lambda, I am trying to pass message attributes to the SQS but when I hit the endpoint in postman I keep getting a 400 Bad Request.. what is the right way to send the attributes over a JSON POST body
here is body from postman (have tried a few options based on this link)
"message": "Message",
"MessageAttributes": {
"Name": "Name",
"Type": "String",
"Value": "my value"
}
}
Here is how API Gateway is configured
Incase someone stumbles on this later here is worked from the CDK side
let intergation = new apiGateway.CfnIntegration(this, 'Integration', {
apiId: props.httpApi.httpApiId,
payloadFormatVersion: '1.0',
integrationType: 'AWS_PROXY',
credentialsArn: apigwRole.roleArn,
integrationSubtype: 'SQS-SendMessage',
requestParameters: {
QueueUrl: sqsqueue.queueUrl,
MessageBody: '$request.body',
MessageAttributes: '$request.body.MessageAttributes'
}
})
new apiGateway.CfnRoute(this, 'Route', {
apiId: props.httpApi.httpApiId,
routeKey: apiGateway.HttpRouteKey.with('/url/foo', apiGateway.HttpMethod.POST).key,
target: `integrations/${intergation .ref}`
}).addDependsOn(intergation);
and the cloudformation
MessageBody: $request.body
MessageAttributes: $request.body.MessageAttribute
then in post man the POST body content type as application/json
{
"message": "Message",
"MessageAttributes": {
"Attributes": {
"DataType": "String",
"StringValue": "my value"
}
}
}
the lamba would log out both separate for each Record from the event body
Records: [
{
....
body: 'Message',
attributes: [Object],
messageAttributes: [Object]
}
]
}
the messageAttributes object from above:
{
Attributes: {
stringValue: 'my value',
stringListValues: [],
binaryListValues: [],
dataType: 'String'
}
}
This is using AWS API Gateway v2 HTTP API also

Remove swagger definitions from sonar coverage

When I push my code to sonar, it mentioned below type of codes not cover by unit tests(Jest JS). How to remove this kind of swagger definition code from code coverage in sonar.
#ApiOperationPost({
description: "Student details",
summary: "Student details",
path: "/student",
security: {
authorization: [],
},
parameters: {},
responses: {
200: {
description: "Student details request",
model: "StudentDetailsRequest",
type: SwaggerDefinitionConstant.Response.Type.ARRAY,
},
400: { description: "Expected Parameters Missing", model: "Problem" },
401: { description: "Unauthorized", model: "Problem" },
500: { description: "Internal Server Error", model: "Problem" },
},
})
Please help me to solve this issue. Any help or workarounds are really appreciated.

How to add service-account to instance template with deployment manager

I am trying to create simple VM based on example given in here1.
I want to add custom service account 2 to this VM.
My config looks something like this
def GenerateConfig(context):
"""Create instance with disks."""
resources = [{
'type': 'compute.v1.instance',
'name': 'vm-' + context.env['deployment'],
'properties': {
'zone': context.properties['zone'],
'disks': [{
'deviceName': 'boot',
'type': 'PERSISTENT',
'boot': True,
'autoDelete': True,
'initializeParams': {
'diskName': 'disk-' + context.env['deployment'],
}
}],
'networkInterfaces': [{
'network': '...',
'subnetwork': '...',
'no-address': True,
}],
'tags':{
'items': [context.env['deployment']]
},
'service-account': ''.join(['custom-compute#',
context.env['project'],
'.iam.gserviceaccount.com']),
'scopes': ['https://www.googleapis.com/auth/devstorage.read_only',
'https://www.googleapis.com/auth/logging.write',
'https://www.googleapis.com/auth/monitoring.write',
'https://www.googleapis.com/auth/trace.append']
}
}]
return {'resources': resources}
I am able to successfully create the deployment. However when I describe the newly created instance it doesn't have any "service-account" associated with the vm.
I couldn't find any example of adding service-account to Deployment manager template. I have also tried to use "serviceAccount" key instead of 'service-account' without any success.
Does anyone knows what I am missing?
I found the reference DM reference docs.
The required changes were
'serviceAccounts': [{
'email': '....',
'scopes': '...'
}]

API Gateway CreateAuthorizer fails with InternalFailure

When I try to create custom authorizerer for my AWS API Gateway using CloudFormation, it freezes trying all the time to execute CreateAuthorizer call, but fails. Here is the minimum CloudFormation template with which I can reproduce that behavior:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
ApiGatewayV1:
Type: "AWS::ApiGateway::RestApi"
Properties:
Name: "test"
ApiAuthorizerV1:
Type: "AWS::ApiGateway::Authorizer"
Properties:
RestApiId: !Ref "ApiGatewayV1"
Name: "test"
Type: "TOKEN"
AuthorizerUri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda::${AWS::AccountId}:function:${!stageVariables.AuthorizerLambdaName}/invocations"
IdentitySource: "method.request.header.Authorization"
AuthorizerResultTtlInSeconds: 3600
CloudTrail log:
"errorCode": "InternalFailure",
"errorMessage": "An unknown error occurred",
"requestParameters": {
"restApiId": "lweme6j3wk",
"createAuthorizerInput": {
"providerARNs": [],
"identitySource": "method.request.header.Authorization",
"authorizerResultTtlInSeconds": 3600,
"type": "TOKEN",
"name": "test",
"authorizerUri": "arn:aws:apigateway:eu-central-1:lambda:path/2015-03-31/functions/arn:aws:lambda::<ACCOUNT_ID>:function:${stageVariables.AuthorizerLambdaName}/invocations"
},
"template": false
},
"responseElements": null,
"requestID": "470e2efa-d3c1-11e7-b0cc-b7fd2383ef6b",
"eventID": "2ceccaa5-9b97-4b1e-93e5-3c4e6bca419d",
Ok, that was supper bizzare. When I explicitely specified region in the target lambda ARN it worked!
Replaced:
arn:aws:lambda::<ACCOUNT_ID>
With:
arn:aws:lambda:<REGION>:<ACCOUNT_ID>
(and yes, it works with ${AWS::Region}:${AWS::AccountId} placeholder, I used fixed values to check.