Posts tagged with amazon-web-services

just wondering if someone can help me with this issue: I am trying to run a code in a lambda function and I have created a layer for this using a docker to create the needed libs:

# Use an official Amazon w/python3 FROM public.ecr.aws/lambda/python:3.9 # Create and activate a virtual environment RUN python3.9 -m venv /app/venv ENV PATH="/app/venv/bin:$PATH" # Install required packages COPY . . RUN pip3 install --upgrade pip RUN pip3 install --platform manylinux2014_x86_64 --target ./venv/lib/python3.9/site-packages --python-version 3.9 --only-binary=:all:  -r requirements.txt 
when i upload the function code and test it i am receiving this error: [ERROR] Runtime.ImportModuleError: Unable to import module 'google_conversion_lambda': google-ads Traceback (most recent call last):INIT_REPORT Init Duration: 3853.19 ms Phase: init Status: error   Error Type: Runtime.Unknown [ERROR] Runtime.ImportModuleError: Unable to import module 'google_conversion_lambda': google-ads Traceback (most recent call last):INIT_REPORT Init Duration: 25715.69 ms    Phase: invoke   Status: error   Error Type: Runtime.Unknown 

the import is coded like this:

from google.ads.googleads.client import GoogleAdsClient 

its is weird and I am running out of ideas to try. Any suggestions or other leads that I can try?

I already tried:

  1. On the code Zip file include all the google libraries needed along with the function.
  2. Rebuilding as a layer, with other building methods using the docker.

Both shows the same results.

EDIT: Just to let you know the issue here is that I was zipping the files on a windows environment and even the zipping process should happen inside the docker environment (Linux) after that we are good to export the zip file and update the layer.

I am using the Facebook Ads connector in AWS AppFlow to transfer Facebook Ads data. While I can successfully transfer all data objects, the data for ads is being accumulated over the entire lifetime of the ads rather than on a daily basis.

For instance, when generating reports using Facebook's Graph API, I retrieve daily data as follows:

https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-19','until':'2021-08-20'} https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-20','until':'2021-08-21'} https://graph.facebook.com/{ad_id}/insights?fields={field_names}&time_range={'since':'2021-08-21','until':'2021-08-22'} 

I would like to achieve the same daily data transfer using AWS AppFlow for the entire duration the ad has been running. How can I configure AWS AppFlow to transfer the ads data on a daily basis instead of the accumulated data over the ad's lifetime? Any guidance or examples would be greatly appreciated.

I have got the following data transferred for the lifetime of ad run between 2021-08-17 and 2024-06-05

{"account_currency":"USD","account_id":"","account_name":"","actions":[{"action_type":"onsite_conversion.post_save","value":"7"},{"action_type":"comment","value":"10"},{"action_type":"link_click","value":"433"},{"action_type":"post","value":"39"},{"action_type":"like","value":"3969"},{"action_type":"post_reaction","value":"2847"},{"action_type":"page_engagement","value":"7305"},{"action_type":"post_engagement","value":"3336"}],"ad_id":"","ad_name":"","adset_id":"","adset_name":"","buying_type":"AUCTION","campaign_id":"","campaign_name":"","clicks":"8000", "date_start":"2021-08-17","date_stop":"2024-06-05" 

What I need is a daily level data transfer for all the days between 2021-08-17 and 2024-06-05 i.e, for all the days the ad has run.

I am trying to setup a webhook in AWS Lambda (using API Gateway) for Meta's WhatsApp Business API. They have the following guidelines:

Whenever your endpoint receives a verification request, it must:

Verify that the hub.verify_token value matches the string you set in the Verify Token field when you configure Webhooks in your App Dashboard (you haven't set up this token string yet). Respond with the hub.challenge value."

I have setup all the query strings it needs in the API gateway. Here is what my lambda handler looks like:

def lambda_handler(event, context):     response = {         "status": 400,         "body" : "failed"     }          print(str(event))          print("Received context" + str(context))          if(len(event) != 0 and (event['hub.verify_token'] == "some value")):         response['status'] = 200         response['body'] = event['hub.challenge']         return event['hub.challenge']               #print(response)         #returnResponse = re.findall('[0-9]+', event['hub.challenge'])         #return returnResponse[0]              else:         return(response) 

the event looks like:

{     "hub.mode" : "some value",     "hub.verify_token": "some value",     "hub.challenge": "1158201444" } 

The response in AWS console looks like "1158201444" but on meta's end, the response looks like "\"1158201444\"" and the webhook confirmation fails in Meta's dashboard.

How can remove the extra characters and decode the string? I have already tried regex and still getting the extra characters (\"\").

Does Boto3 client support connectors for GoogleAds and FacebookAds? According to documentation we can use Custom Connector but when i try to use it in the code i get the below error saying it should be one of the built in types.

[ERROR] ParamValidationError: Parameter validation failed: Unknown parameter in connectorProfileConfig.connectorProfileProperties: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData Unknown parameter in connectorProfileConfig.connectorProfileCredentials: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData Traceback (most recent call last):   File "/var/task/lambda_function.py", line 34, in lambda_handler     response = client.create_connector_profile(   File "/var/runtime/botocore/client.py", line 391, in _api_call     return self._make_api_call(operation_name, kwargs)   File "/var/runtime/botocore/client.py", line 691, in _make_api_call     request_dict = self._convert_to_request_dict(   File "/var/runtime/botocore/client.py", line 739, in _convert_to_request_dict     request_dict = self._serializer.serialize_to_request(   File "/var/runtime/botocore/validate.py", line 360, in serialize_to_request     raise ParamValidationError(report=report.generate_report()) 

Code in Lambda :

import json import boto3 def lambda_handler(event, context):     client = boto3.client('appflow')        ### Google Ads     response = client.create_connector_profile(     connectorProfileName='GoogleAdsConn',     connectorType='CustomConnector',     # connectorLabel='GoogleAds',     connectionMode='Public',     connectorProfileConfig= {       "connectorProfileProperties": {           'CustomConnector': {                 # 'profileProperties': {                 #     'string': 'string'                 # },                 'oAuth2Properties': {                     'tokenUrl': 'https://oauth2.googleapis.com/token',                     'oAuth2GrantType': 'AUTHORIZATION_CODE'                     # ,'tokenUrlCustomProperties': {                     #     'string': 'string'                     # }                 }             }             },       "connectorProfileCredentials": {         "CustomConnector": {              "authenticationType": "OAUTH2",             "oauth2": {                 "accessToken": "myaccesstoken",                "clientId": "myclientid",                "clientSecret": "myclientsecret",               "oAuthRequest": {                   "authCode": "string",                  "redirectUri": "string"               },                "refreshToken": "myrefreshtoken"             }       }     }        }    )     return {         'response': response     } 

Any leads on this will be appreciated.
Thanks!

I'm trying to use AWS AppFlow to ingest Google Ads supported objects to AWS S3. Though i have successfully created connections using GoogleAds Connector I'm unable to ingest the data to S3.

Steps followed from AWS console:
Step 1: Name of the flow was provided.
Step 2: Configure Source and Destination. Recently created Google Ads Connection was chosen for source and AWS S3 bucket for destination. Flow Trigger is set to ‘Run on Demand’ (Step2 Figure )
Step 3: Map Data Fields: This page throws the error. (Step3 Figure)

I have followed all the steps as it is from AWS Doc
Error Message:

An error occurred while retrieving fields Error while communicating to connector: The request failed because the service Source Customconnector returned the following error: Details: GoogleAds metadata response can not be null or empty, ErrorCode: ServerError.


I also tried changing the mapping method and chose to upload a mapping csv file but even it failed with the error "Couldn't parse rows from the file."


Alternatively when trying to retrieve the campaign object from the python script it returns the desired output.

Any leads around this will be appreciated.
(Also this is my first post on stack overflow :P)