AWS RDS DB Parameter Group in CloudFormation - amazon-rds

I'm trying to create a custom DBParameterGroup as part of the CloudFormation stack to launch SQL instance using below resource definition -
CustomDBParameterGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: !Join [' ', ['Custom Option Group for application - ', !Ref AppName, !Ref EnvironmentType]]
Family: sqlserver-ee-13.0
Parameters:
remote_access: 0
When I launch the stack, I get the error -
Invalid / Unsupported DB Parameter: remote_access
What is the correct parameter attribute key/value combination to
disable remote access in the parameter group? Unable to find this in
AWS documentation. Appreciate if anyone can help.
Thanks!

I found the answer. Change the remote_access to remote access (with a space) and the custom DBParameterGroup will be created with the set value of 0.
CustomDBParameterGroup:
Type: AWS::RDS::DBParameterGroup
Properties:
Description: !Join [' ', ['Custom Option Group for application - ', !Ref AppName, !Ref EnvironmentType]]
Family: sqlserver-ee-13.0
Parameters:
remote access: 0

Related

Display agents API ADO with SystemCapabilities filter

how can I display the ADO agents using the ADO API, but so as to filter out the agents that in System Capabilities have e.g. key=value
i tried:
https://dev.azure.com/org/_apis/distributedtask/pools/111/agents?capabilities=key=value&api-version=5.1
https://dev.azure.com/org/_apis/distributedtask/pools/111/agents/?key=valueA&api-version=5.1
https://dev.azure.com/org/_apis/distributedtask/pools/111/agents?demands=SystemCapabilities.key=value&api-version=5.1
It shows me all agents in pool 111
You can try to use demands: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml#manually-entered-demands
pool:
name: MyPool
demands:
- myCustomCapability # exists check for myCustomCapability
- Agent.Version -equals 2.144.0 # equals check for Agent.Version 2.144.0
as a template:
https://dev.azure.com/{org}/_apis/distributedtask/pools/{poolId}/agents?includeCapabilities=true&demands=your_capability -equals value
as an example:
https://dev.azure.com/{org}/_apis/distributedtask/pools/{poolId}/agents?includeCapabilities=true&demands=Agent.Version%20-equals%202.213.2

Google Cloud Datastore Index not found even if it is set

I have a kind named 'audit' and has many properties however, I need to index only certain properties and in a specific order since I mostly query:
select DISTINCT ON (traceId) * from audit where tenantId='123'
When I try to run this in the GCP console it throws an error:
GQL Query error: Your Datastore does not have the composite index (developer-supplied) required for this query.
I also tried running this from a node js application that uses #google-cloud/datastore package, and datastore throws error:
9 FAILED_PRECONDITION: no matching index found. recommended index is:
- kind: audit
properties:
- name: tenantId
- name: traceId
The index.yaml is created using terraforms and the contents are:
indexes:
- kind: "audit"
properties:
- name: "tenantId"
- name: "traceId"
# AUTOGENERATED
# This index.yaml is automatically updated whenever the Cloud Datastore
# emulator detects that a new type of query is run. If you want to manage the
# index.yaml file manually, remove the "# AUTOGENERATED" marker line above.
# If you want to manage some indexes manually, move them above the marker line.
With this index.yaml file the local datastore emulator works as expected.
In the GCP console, I see the index being set and is in serving status.
It seems you have additional quotes, " around your Datastore property names in the index.yaml file.
indexes:
- kind: Cat
properties:
- name: name
- name: age
Please refer to the documentation on correct syntax.
On the Google Provider Terraform side, there is a ~> Warning mentioned, make sure to follow it to create a compatible database type. Refer here for more details on compatibility settings.

How to wait for CodePipeline to deploy the function in Cloudformation

I have a Cloudformation template and I wanted to create Aurora(MySQL) tables through it. However, there is no built-in resource for it. So, I decided to build a custom resource function to create tables upon DbCluster creation. Moreover, as CI/CD Pipelines can also be created by Cloudformation, I prepared a template like below. However, it throws an error:
Function not found: arn:aws:lambda:eu-central-1:xxxxxxxxxxxx:MyFunctionName (Service: AWSLambda; Status Code: 404; Error Code: ResourceNotFoundException; Request ID: ...)
Apparently, the CustomResource runs whenever Pipeline is created. But I need to wait for its first deployment of function in order to use it in custom resource. Thought the property RestartExecutionOnUpdate: true in AWS::CodePipeline::Pipeline and adding DependsOn in Custom::RdsBootstrap would help but they did not.
Resources:
# Serverless Aurora DB Cluster
MyDbCluster:
Type: AWS::RDS::DBCluster
...
# Build Project
MyCustomResourceFunctionBuildProject:
Type: AWS::CodeBuild::Project
...
# Pipeline for deploying Custom Resource Function Source Code
MyCustomResourceFunctionPipeline:
Type: AWS::CodePipeline::Pipeline
Properties:
Name: custom-resource-function-pipeline
RestartExecutionOnUpdate: true
Stages:
- Name: Source
...
- Name: Build
...
- Name: Pipeline
...
# Custom Resource Function
RdsBootstrap:
Type: Custom::RdsBootstrap
DependsOn: [MyDbCluster, MyCustomResourceFunctionPipeline]
Version: '1.0'
Properties:
ServiceToken: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:MyFunctionName"
So, how to make the custom resource not only wait for CodePipeline creation; but also its initial deployment?

AWS SAM FindInMap Not Populating Variable

I am trying to get a simple SAM template to populate environmental variables "dynamically" using the !FindInMap intrinsic function. I have followed many examples, including AWS's documentation, without any luck. For some reason the function will not populate environment variables using it even though everything seems to be correct. It will just set the variable to an empty string.
You can see from the code below that I am using a !Ref function inside of it, but have tried hardcoding the parameters of the function without any luck. You'll also notice that the function is in the Global section, and you may think it's not working because it's there and not function environmentals, but I've tried both with neither of them working. You'll also notice that I am populating a environment variable called STAGE which is working correctly and setting it to "local".
I am testing the function by running sam start local-api and outputting the environment variables in the response.
Any suggestions would be very helpful.
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: "Test Server"
Parameters:
Environment:
Type: String
Default: local
AllowedValues:
- local
- test
- prod
Mappings:
EnvParams:
local:
stage: "local"
databaseUrl: "mongodb://localhost:32768/test"
Globals:
Function:
Timeout: 500
Runtime: nodejs8.10
Environment:
Variables:
STAGE: !Ref Environment
DB_URL: !FindInMap [EnvParams, !Ref Environment, databaseUrl]
Resources:
ArticlesGetFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: src/articles/
Handler: index.getById
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /api/article/
Method: get
Outputs:
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
It looks like !FindInMap isn't supported in local debugging yet. Here's the relevant GitHub issue:
https://github.com/awslabs/aws-sam-cli/issues/476
To set and test Environment Variables in SAM CLI, you can use the --env-vars option instead. !FindInMap is also supported when deployed via CloudFormation, you could test this feature by deploying a simple Lambda function and running a test query against it.
I had similar error because of this:
!FindInMap [EnvMap, !Ref Stage, dbpass] - correct
!FindInMap [EnvMap, !Ref Stage, dbpass] - error

I am getting error: mappings value are not allowed here whenever I am running the yml policy to tag the instance

I am trying this policy to tag the instance in ec2. I am running this policy by cloud custodian.
help me to solve the issue
policies:
- name:tag_policy
resource:ec2
actions:
- type: tag
key:mykey
value:myvalue
I did mistake in the given given that I had written. There must be space after colon so the final code is:
policies:
- name:tag_policy
resource: ec2
actions:
-type: tag
key: mykey
value: myvalue

Resources