openstack heat doesn't recognize key_name parameter - openstack

hy
i have an openstack deployed on my laptop. i'm trying to create a stack with heat.
i have created a keypair openstack keypair create heat_key > heat_key.priv
which is recognized by nova nova keypair-list give the following output :
+----------+------+-------------------------------------------------+
| Name | Type | Fingerprint |
+----------+------+-------------------------------------------------+
| heat_key | ssh | 0b:7a:36:20:e2:e3:19:3b:ab:a1:95:ac:67:41:67:d7 |
+----------+------+-------------------------------------------------+
this is my simple HOT template :
heat_template_version: 2013-05-23
description: Hot Template to deploy a single server
parameters:
image_id:
type: string
description: Image ID
key_name:
type: string
description: name of keypair to enable ssh to the instance
resources:
test_stack:
type: OS::Nova::Server
properties:
name: "test_stack"
image: { get_param: image_id }
flavor: "ds1G"
key_name:{ get_param: key_name }
outputs:
test_stack_ip:
description: IP of the server
value: { get_attr: [ test_stack, first_address ] }
when i try to create the stack
openstack stack create -t myTemp.hot --parameter key_name=heat_key --parameter image_id=trusty-server-cloudimg-amd64-disk1 test_stack
i get the following error
ERROR: Property error: : resources.test_stack.properties: : Unknown Property key_name:{ get_param
i have tried with different versions of templates but i get the same error
any idea why this is happening?

WORST part about the YAML file is, it is SPACE sensitive, so we need to be really careful while editing or copying conetent of HEAT templete. There is no space between "key_name" and "{" which is why it is failing.
key_name:{ get_param: key_pair_name }
Just put an extra space between these and it will work. I tested it :-)
key_name: { get_param: key_pair_name }

I was able to do it by providing the details in parameters . PFB Sample script which worked for me.
heat_template_version: 2016-10-14
description: Admin VM - Test Heat
parameters:
image_name_1:
type: string
label: Centos-7.0
description: Centos Linux 7.0
default: Centos-7.0
network_id_E1:
type: string
label: 58e867ce-841c-48cf-8116-e72d998dbc89
description: Admin External Network
default: Admin
network_id_E1:
type: string
label: 4f69c8e5-8f52-4804-89e0-2c8232f9f3aa
description: Internal-1 Network
default: SR-IOV Interface
network_id_I2:
type: string
label: 28120cdb-7e8b-4e8b-821f-7c7d8df37c1d
description: Internal-2 Network
default: Internal-2
KeyName:
type: string
default: IO_Perf_Cnt
description: Name of an existing key pair to use for the instance
constraints:
- custom_constraint: nova.keypair
description: Must name a public key (pair) known to Nova
resources:
AdminVM1:
type: OS::Nova::Server
properties:
availability_zone: naz3
image: { get_param: image_name_1 }
flavor: 4vcpu_8192MBmem_40GBdisk
key_name: { get_param: KeyName }
networks:
- network: { get_param : network_id_E1 }

Try to change the parameter name key_name to some other name and execute it
heat_template_version: 2015-10-15
description: Hot Template to deploy a single server
parameters:
image_id:
type: string
description: Image ID
key_pair_name:
type: string
description: name of keypair to enable ssh to the instance
resources:
test_stack:
type: OS::Nova::Server
properties:
name: "test_stack"
image: { get_param: image_id }
flavor: "ds1G"
key_name: { get_param: key_pair_name }
outputs:
test_stack_ip:
description: IP of the server
value: { get_attr: [ test_stack, first_address ] }

Related

Error getting keys from Azure Storage Account with listkeys(...) method with Bicep syntax

I have a Bicep template to create an Azure Storage Account
#description('the name of the storage account')
param name string
#description('the alias of the storage account')
param shortName string
#description('tags')
param tags object
#description('the name of the key vault resource where place output secrets')
param keyVaultName string
resource storageAccount 'Microsoft.Storage/storageAccounts#2022-09-01' = {
name: name
location: resourceGroup().location
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
tags: union(tags, {
type: 'storage-account'
})
}
Then, I need to get the keys
var keys = listkeys(storageAccount.id, storageAccount.apiVersion)
output keyObject object = keys[0]
output KeyValue string = keys[0].value
But everytime that I runs the template, I receive these errors:
{
"code": "DeploymentOutputEvaluationFailed",
"message": "Unable to evaluate template outputs: 'keyObject,keyValue'. Please see error details and deployment operations. Please see https://aka.ms/arm-common-errors for usage details.",
"details": [
{
"code": "DeploymentOutputEvaluationFailed",
"target": "keyObject",
"message": "The template output 'keyObject' is not valid: The language expression property '0' can't be evaluated, property name must be a string.."
},
{
"code": "DeploymentOutputEvaluationFailed",
"target": "keyValue",
"message": "The template output 'keyValue' is not valid: The language expression property '0' can't be evaluated, property name must be a string.."
}
]
}
The purpose of get keys is to save it into Azure Key Vault by using KeyValue var from previous step
resource keyVault 'Microsoft.KeyVault/vaults#2022-07-01' existing = {
name: keyVaultName
}
resource secret 'Microsoft.KeyVault/vaults/secrets#2022-07-01' = {
parent: keyVault
name: secretName
properties: {
value: KeyValue
contentType: 'plain/text'
}
}
So..
What's wrong with listKeys(...) method?
By following this tweet https://twitter.com/adotfrank/status/1341084692100108288?s=46&t=sWx0hvS0sS47llWLlbWZTw I found an alternative method to get keys.
Just referencing to a storage account object and use the method listKeys()
resource storageAccount 'Microsoft.Storage/storageAccounts#2022-09-01' = {
name: name
location: resourceGroup().location
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
tags: union(tags, {
type: 'storage-account'
})
}
var storageAccountKeys = storageAccount.listKeys()
Then, I can access to primary or secondary key with storageAccountKeys.keys[0].value
This fix solve my issue.

Add new NIC to existing Subnet

I have an existing vNet and subnet and I'm trying to deploy a new NIC to the Subnet with the following bicep
param location string = resourceGroup().location
param nicName string
param vNetName string
param subnetName string
resource vnet 'Microsoft.Network/virtualNetworks#2021-02-01' existing = {
name: vNetName
scope: resourceGroup('myRgName')
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets#2021-02-01' existing = {
parent: vnet
name: subnetName
}
resource nsg 'Microsoft.Network/networkSecurityGroups#2021-08-01' = {
name: '${nicName}-nsg'
location: location
}
resource nic 'Microsoft.Network/networkInterfaces#2021-08-01' = {
name: nicName
location: location
dependsOn: [
subnet
]
properties: {
ipConfigurations: [
{
name: 'ipConfig'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: subnet
primary: true
privateIPAddressVersion: 'IPv4'
}
}
]
networkSecurityGroup: nsg
}
}
I compile the template and try to deploy but I'm getting the error Value for reference id is missing. Path properties.ipConfigurations[0].properties.subnet. which appears to be caused by the ARM not finding the subnet (which exists and I have access to).
The json portion of it looks like this
"subnet": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, 'myRgName'), 'Microsoft.Network/virtualNetworks/subnets', split(parameters('subnetName'), '/')[0], split(parameters('subnetName'), '/')[1]), '2021-02-01', 'full')]",
Use
subnet: {
id: subnet.id
}
for the subnet reference in the NIC's properties... you'll need the same for the networkSecurityGroup as Thomas mentioned.

Amplify JS API GraphQL Elasticsearch throws "ResolverExecutionLimitReached" error

I've implemented the Amplify JS Library with a Vue project and have had success with all of the features of the library except this issue. When I query a model with Elasticsearch, it returns the appropriate results, but also the error of "ResolverExecutionLimitReached".
This is the request:
let destinations = await API.graphql(graphqlOperation(queries.searchDestinations, {filter: { deviceId: { eq: params.id }}}))
This is the schema:
type Destination
#model
#searchable
#auth(rules: [{ allow: public }, { allow: private }])
#key(name: "byXpoint", fields: ["xpoint"])
#key(name: "byDevice", fields: ["deviceId"])
{
id: ID!
index: Int!
levels: [String]
name: String!
xpoint: String
sourceId: ID
Source: Source #connection
lock: Boolean
breakaway: Boolean
breakaways: String
probeId: ID!
probe: Probe #connection(fields: ["probeId"])
deviceId: ID!
device: Device #connection(fields: ["deviceId"])
orgId: ID!
org: Org #connection(fields: ["orgId"])
}
And this returns:
{
data: {
searchDestinations: {items: Array(100), nextToken: "ba1dc119-2266-4567-9b83-f7eee4961e63", total: 384}
},
errors: [
{
data: null
errorInfo: null
errorType: "ResolverExecutionLimitReached"
locations: []
message: "Resolver invocation limit reached."
path: []
}
]
}
My understanding is the AppSync API has a hard limit of returning more than 1000 entries, but this query is on a table with only ~600 entries and is only returning 384. I am executing the same command via AppSync directly via a NodeJS application and it works without issue.
Not sure where to investigate further to determine what is triggering this error. Any help or direction is greatly appreciated.
Connections in the schema were causing the single request to go beyond the 1000 request limit (exactly as stated by Mickers in the comments). Updated schema with less connections on fetch and issue was resolved.

Error: Resolver associated with data sources

I'm having the serverless error:
Resolver associated with data sources when building from serverless.yml config file:
# serverless.yml
...
mappingTemplates:
- dataSource: Wallet
type: Query
field: walletFromId
request: "_dynamo-get-wallet.txt"
response: "_generic-result-response.txt"
- dataSource: Wallet
type: Query
field: walletsFromUser
request: "_dynamo-get-wallets-from-user.txt"
response: "_generic-result-response.txt"
- dataSource: Wallet
type: Mutation
field: registerWallet
request: "_dynamo-put-wallet.txt"
response: "_generic-result-response.txt"
dataSources:
- type: AMAZON_DYNAMODB
name: Wallet
description: 'Wallet DataSource'
config:
tableName: "${self:custom.stage}-Wallet"
serviceRoleArn: "arn:aws:iam::${self:custom.accountId}:role/${self:custom.appSync.serviceRole}"
...
I also have a schema.graphql:
type Query {
# query the wallet with given id and get the output with detail info
walletFromId(walletId: String!): Wallet!
# query wallets with given user id and get list of cards
walletsFromUser(userId: String!): [Wallet!]!
}
type Mutation {
# Add a wallet to an existing user
registerWallet(userId: String!, number: String!, cvx: String!, expirationDate: String!): Wallet!
}
type Wallet {
walletId: String!
userId: String!
number: String!
cvx: String!
expirationDate: String!
}
type Subscription {
addWallet: Wallet
#aws_subscribe(mutations: ["registerWallet"])
}
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
I could not find a single clue as to what this error mean, and there isn't anything else I can get from the build logs.
This error usually means you are trying to delete a data source that is currently being used by a resolver. If you can identify the resolver pointing to the data source and delete it then you should no longer see the error message.

Integrating cloudify with openstack nova-network

Integrating cloudify with openstack nova-network, if nova-network dosn't support floating-ip, how to define the openstack-nova-net-manager-blueprint.yaml?
1.cloudify-manager-blueprints version: cloudify-manager-blueprints-3.2.1
https://github.com/cloudify-cosmo/cloudify-manager-blueprints/tree/3.2.1-build
2.the blueprint DSL like this:
enter image description here
how to solve this problem? thanks for your kindly help!
The floating IP is used to connect to the manager once it has been already bootstrapped.
In case you do not have a floating IP, you can bypass it with one of two options:
Create manually an IP connected to the external network and use it as an external resource, so you it would look like:
manager_server_ip:
type: string
default: 1.1.1.1
manager_server:
type: cloudify.openstack.nodes.Server
properties:
resource_id: { get_input: manager_server_name }
manager_server_ip: { get_input: manager_server_ip }
install_agent: false
server:
image: { get_input: image_id }
flavor: { get_input: flavor_id }
openstack_config: { get_property: [openstack_configuration, openstack_config] }
relationships:
- target: management_security_group
type: cloudify.openstack.server_connected_to_security_group
- target: management_keypair
type: cloudify.openstack.server_connected_to_keypair
Just create a regular IP on the some network that will let you connect the manager after bootstrap

Resources