How to change or override smtp_password for Google Composer Airflow - smtp

I am trying to do a setup of smtp server in Google Composer Airflow, as per the google document smtp_password can not be overridden and default password should be used.
Is there any option to use smtp server with actual password in Google Cloud Composer.

According to the documentation, some Airflow configurations are preconfigured for Cloud Composer and you cannot change them like smtp-smtp_password after the new environment is already created.
You can receive notifications by configuring SENDGRID_MAIL_FROM and SENDGRID_API_KEY environment variables to send email through the SendGrid email service using the SendGrid API key instead of smtp_password.
Additionally, you can configure third-party SMTP services but consider that Cloud Composer does not support configuring the smtp_password because the value is stored in plain text in airflow.cfg and considered unsecure.

Related

Do I have to call Firebase Remote Config API from the Cloud Function?

I have some params in Remote Config that I want to update from the Google Cloud Functions.
Should I use the Remote Config API when both Cloud Functions and Remote Config belong to the same account or project?
I am asking because Cloud Functions can directly import the data from Firestore without any authentication and API.
Remote Config provided the RESTful APIs to update the parameters or template.
You don't have to call them from a Google Cloud function. But calling them from a Google Cloud function or even Firebase Cloud function is definitely workable.
You can even call the RESTful APIs from postman or some other tools once you set up the call properly.
Check more details here: https://firebase.google.com/docs/reference/remote-config/rest
With Remote Config backend APIs, you could use Remote Config with Cloud Functions for Firebase, changing values in your app based on events that happen server-side. For example, you can use Remote Config to promote a new feature in your app, and then turn off that promotion automatically once you detect enough people have interacted with the new feature.
Using the Remote Config REST API or the Admin SDKs described in this guide, you can bypass managing the template in the Firebase console to directly integrate Remote Config changes into your own processes.
As described here, Cloud Functions can be triggered in response to changes in Firebase Remote Config in the same Cloud project as the function. This makes it possible to change the behavior and appearance of your app without publishing an app update.

is there any way to login zabbix API without giving Username ans password in script

I am using pyzabbix module to use the Zabbix API, but is there any way to login the Zabbix API without giving the username and password in Python script?
Like any API token which serves the purpose.
There are no API tokens or similar access methods in Zabbix currently.
There is not, but you should use an environment variable (see environment variable in python) to store the password/token anyway, in order to avoid having it inside the code in cleartext. The environment is visible to the user only, and is usually initialized from a protected file (0600 permission in unix style), or a masked CI/CD variable.
I am using Zabbix 5.4.7
There is a section API tokens under:
Administration -> General -> API tokens

Integrating KeyVault access into VSTS Release task

I am trying to figure out what is involved to write a console application that will run as part of a VSTS Release task and that program will read a connection string (secret) from a preconfigured keyvault and then connect to an Azure SQL db using that connection string and apply some changes.
Currently I have my Web Apps connecting to KeyVault and the Azure SQL Server
using Azure AD Application Token authentication so I know what is involved on that front.
When you check "Allow scripts to access OAuth token" on agent settings page,
can this token be used (using ADAL) to connect to KeyVault and SQL Server.
(Assuming the VisualStudioSPNxxx has the appropriate access to the above resources).
If not what should I be looking for?
The vsts token (Allow scripts to access OAuth token) can’t be used to connect to KeyVault.
You need to register app with Azure Active Directory and enable to communicate with Azure Active Directory and Key Vault, then get the connectionstring dynamically.
More information, you can refer to: Protecting Secrets using VSTS and Azure Key Vault
This is made relatively very easy now with Variable Groups - https://learn.microsoft.com/en-us/vsts/pipelines/library/variable-groups?view=vsts
You can link a secret by connecting your Azure KV to a variable and then use this variable as you would normally use it in any script/task.

Unable to send mails with SMTP in GCE instances

While migrating from AWS EC2 instances to Google Compute Engine instances we got problems with sending emails via SMTP (Sendgrid).
I read a lot about it and read that the ports (587, 462, 25) of SMTP are blocked... And to read this article.
https://cloud.google.com/compute/docs/tutorials/sending-mail/#sending_mail_through_corporate_mail_servers
Questions:
For my understanding we should open a Cloud Launcher of SendGrid?
If (1) = yes, then I see it (the cloud launcher) does not support C# and our code today of sending emails is based on C#. So that we will have to change the code to one of those: Node.js, Python, Ruby, Go & PHP?
Is there any way to unblock this outbound connections on port 587 (or 462, 25)? Without Cloud Launcher.
Thanks in advance
1) Yes, if you want to use it through google. If not I recommend directly going to one of the smtp providers such as sendgrid, spakpost, mandrill... to get and account and use their smtp service to send mail.
2) You can use C# by simply not using the Cloud Launcher and purchasing an account directly from the vendor and usning their SMTP service.
3) No, port 2525 is free to send outbound emails to smtp providers through GCP so I highly recommend using that since it can be used for sendgrid as well.

Using Google Compute API automated over as server

I'm using the Google client API library for Python. My code is running on an Ubuntu 14.04LTS server.
I have a working Google Compute project, were I created and downloaded a OAuth2.0 token to my server.
I'm trying to write a script that does the following:
Automatically (with no user interaction) authenticate to Google Compute engine.
create a new VM and then perform more actions...
My basic problem is using the OAuth2.0 authentication. It required user approval on a javascript supporting browser, and I want to do it automatically, on my server.
Using my code on my desktop works. A browser page pops up requiring my approval. On my server, I get the following message:
we have detected that your javascript is disabled in your browser
The code segment I use for authentication is:
# authenticate using the OAuth token
client_secret = os.path.join(
os.path.dirname(__file__),
self._oauth_token_path)
# set up a Flow object for the authentication
flow = client.flow_from_clientsecrets(
client_secret,
scope=scope,
message=tools.message_if_missing(client_secret))
# open credential storage path
credential_storage = file.Storage(self._credential_storage_path)
credentials = credential_storage.get()
# get credentails if necessary
if credentials is None or credentials.invalid:
credentials = tools.run_flow(flow, credential_storage, flags)
I read about service account access as a replacement of the regular OAuth2.0 authentication. Does any one know if that's the best way to go? any thoughts on how to do it better?
OAuth 2.0 requires user approval and is not the method to go for if you want to run your code/scripts automatically.
Service accounts are more suitable for this and are supported by the API (https://cloud.google.com/compute/docs/authentication#tools)
You create a service account + key in the developer console and use both to authenticate your application.